1. 21 10月, 2020 1 次提交
  2. 10 8月, 2020 1 次提交
    • E
      test_cmp: diagnose incorrect arguments · d572f52a
      Eric Sunshine 提交于
      Under normal circumstances, if a test author misspells a filename passed
      to test_cmp(), the error is quickly discovered when the test fails
      unexpectedly due to test_cmp() being unable to find the file. However,
      if the test is expected to fail, as with test_expect_failure(), a
      misspelled filename as argument to test_cmp() will go unnoticed since
      the test will indeed fail, but for the wrong reason. Make it easier for
      test authors to discover such problems early by sanity-checking the
      arguments to test_cmp(). To avoid penalizing all clients of test_cmp()
      in the general case, only check for missing files if the comparison
      fails.
      
      While at it, make test_cmp_bin() sanity-check its arguments, as well.
      Signed-off-by: NEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d572f52a
  3. 19 7月, 2020 1 次提交
    • M
      t3200: don't grep for `strerror()` string · d223e854
      Martin Ågren 提交于
      In 6b709306 ("t3200: test for specific errors", 2020-06-15), we
      learned to grep stderr to ensure that the failing `git branch`
      invocations fail for the right reason. In two of these tests, we grep
      for "File exists", expecting the string to show up there since config.c
      calls `error_errno()`, which ends up including `strerror(errno)` in the
      error message.
      
      But as we saw in 4605a730 ("t1091: don't grep for `strerror()`
      string", 2020-03-08), there exists at least one implementation where
      `strerror()` yields a slightly different string than the one we're
      grepping for. In particular, these tests fail on the NonStop platform.
      
      Similar to 4605a730, grep for the beginning of the string instead to
      avoid relying on `strerror()` behavior.
      Reported-by: NRandall S. Becker <rsbecker@nexbridge.com>
      Signed-off-by: NMartin Ågren <martin.agren@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d223e854
  4. 17 7月, 2020 2 次提交
    • J
      repository: allow repository format upgrade with extensions · 62f2eca6
      Jonathan Nieder 提交于
      Now that we officially permit repository extensions in repository
      format v0, permit upgrading a repository with extensions from v0 to v1
      as well.
      
      For example, this means a repository where the user has set
      "extensions.preciousObjects" can use "git fetch --filter=blob:none
      origin" to upgrade the repository to use v1 and the partial clone
      extension.
      
      To avoid mistakes, continue to forbid repository format upgrades in v0
      repositories with an unrecognized extension.  This way, a v0 user
      using a misspelled extension field gets a chance to correct the
      mistake before updating to the less forgiving v1 format.
      
      While we're here, make the error message for failure to upgrade the
      repository format a bit shorter, and present it as an error, not a
      warning.
      Reported-by: NHuan Huan Chen <huanhuanchen@google.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      62f2eca6
    • J
      Revert "check_repository_format_gently(): refuse extensions for old repositories" · 11664196
      Jonathan Nieder 提交于
      This reverts commit 14c7fa26.
      
      The core.repositoryFormatVersion field was introduced in ab9cb76f
      (Repository format version check., 2005-11-25), providing a welcome
      bit of forward compatibility, thanks to some welcome analysis by
      Martin Atukunda.  The semantics are simple: a repository with
      core.repositoryFormatVersion set to 0 should be comprehensible by all
      Git implementations in active use; and Git implementations should
      error out early instead of trying to act on Git repositories with
      higher core.repositoryFormatVersion values representing new formats
      that they do not understand.
      
      A new repository format did not need to be defined until 00a09d57
      (introduce "extensions" form of core.repositoryformatversion,
      2015-06-23).  This provided a finer-grained extension mechanism for
      Git repositories.  In a repository with core.repositoryFormatVersion
      set to 1, Git implementations can act on "extensions.*" settings that
      modify how a repository is interpreted.  In repository format version
      1, unrecognized extensions settings cause Git to error out.
      
      What happens if a user sets an extension setting but forgets to
      increase the repository format version to 1?  The extension settings
      were still recognized in that case; worse, unrecognized extensions
      settings do *not* cause Git to error out.  So combining repository
      format version 0 with extensions settings produces in some sense the
      worst of both worlds.
      
      To improve that situation, since 14c7fa26
      (check_repository_format_gently(): refuse extensions for old
      repositories, 2020-06-05) Git instead ignores extensions in v0 mode.
      This way, v0 repositories get the historical (pre-2015) behavior and
      maintain compatibility with Git implementations that do not know about
      the v1 format.  Unfortunately, users had been using this sort of
      configuration and this behavior change came to many as a surprise:
      
      - users of "git config --worktree" that had followed its advice
        to enable extensions.worktreeConfig (without also increasing the
        repository format version) would find their worktree configuration
        no longer taking effect
      
      - tools such as copybara[*] that had set extensions.partialClone in
        existing repositories (without also increasing the repository format
        version) would find that setting no longer taking effect
      
      The behavior introduced in 14c7fa26 might be a good behavior if we
      were traveling back in time to 2015, but we're far too late.  For some
      reason I thought that it was what had been originally implemented and
      that it had regressed.  Apologies for not doing my research when
      14c7fa26 was under development.
      
      Let's return to the behavior we've had since 2015: always act on
      extensions.* settings, regardless of repository format version.  While
      we're here, include some tests to describe the effect on the "upgrade
      repository version" code path.
      
      [*] https://github.com/google/copybara/commit/ca76c0b1e13c4e36448d12c2aba4a5d9d98fb6e7Reported-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      11664196
  5. 09 7月, 2020 1 次提交
    • T
      commit.c: don't persist substituted parents when unshallowing · ce16364e
      Taylor Blau 提交于
      Since 37b9dcab (shallow.c: use '{commit,rollback}_shallow_file',
      2020-04-22), Git knows how to reset stat-validity checks for the
      $GIT_DIR/shallow file, allowing it to change between a shallow and
      non-shallow state in the same process (e.g., in the case of 'git fetch
      --unshallow').
      
      However, when $GIT_DIR/shallow changes, Git does not alter or remove any
      grafts (nor substituted parents) in memory.
      
      This comes up in a "git fetch --unshallow" with fetch.writeCommitGraph
      set to true. Ordinarily in a shallow repository (and before 37b9dcab,
      even in this case), commit_graph_compatible() would return false,
      indicating that the repository should not be used to write a
      commit-graphs (since commit-graph files cannot represent a shallow
      history). But since 37b9dcab, in an --unshallow operation that check
      succeeds.
      
      Thus even though the repository isn't shallow any longer (that is, we
      have all of the objects), the in-core representation of those objects
      still has munged parents at the shallow boundaries.  When the
      commit-graph write proceeds, we use the incorrect parentage, producing
      wrong results.
      
      There are two ways for a user to work around this: either (1) set
      'fetch.writeCommitGraph' to 'false', or (2) drop the commit-graph after
      unshallowing.
      
      One way to fix this would be to reset the parsed object pool entirely
      (flushing the cache and thus preventing subsequent reads from modifying
      their parents) after unshallowing. That would produce a problem when
      callers have a now-stale reference to the old pool, and so this patch
      implements a different approach. Instead, attach a new bit to the pool,
      'substituted_parent', which indicates if the repository *ever* stored a
      commit which had its parents modified (i.e., the shallow boundary
      prior to unshallowing).
      
      This bit needs to be sticky because all reads subsequent to modifying a
      commit's parents are unreliable when unshallowing. Modify the check in
      'commit_graph_compatible' to take this bit into account, and correctly
      avoid generating commit-graphs in this case, thus solving the bug.
      Helped-by: NDerrick Stolee <dstolee@microsoft.com>
      Helped-by: NJonathan Nieder <jrnieder@gmail.com>
      Reported-by: NJay Conrod <jayconrod@google.com>
      Reviewed-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NTaylor Blau <me@ttaylorr.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ce16364e
  6. 07 7月, 2020 1 次提交
  7. 02 7月, 2020 3 次提交
    • J
      difftool -d: ensure that intent-to-add files are handled correctly · 3080c509
      Johannes Schindelin 提交于
      In https://github.com/git-for-windows/git/issues/2677, a `git difftool
      -d` problem was reported. The underlying cause was a bug in `git
      diff-files --raw` that we just fixed: it reported intent-to-add files
      with the empty _tree_ as the post-image OID, when we need to show
      an all-zero (or, "null") OID instead, to indicate to the caller that
      they have to look at the worktree file.
      
      The symptom of that problem shown by `git difftool` was this:
      
      	error: unable to read sha1 file of <path> (<empty-tree-OID>)
      	error: could not write '<filename>'
      
      Make sure that the reported `difftool` problem stays fixed.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3080c509
    • J
      diff-files --raw: show correct post-image of intent-to-add files · 85953a31
      Johannes Schindelin 提交于
      The documented behavior of `git diff-files --raw` is to display
      
      	[...] 0{40} if creation, unmerged or "look at work tree".
      
      on the right hand (i.e. postimage) side. This happens for files that
      have unstaged modifications, and for files that are unmodified but
      stat-dirty.
      
      For intent-to-add files, we used to show the empty blob's hash instead.
      In c26022ea (diff: convert diff_addremove to struct object_id,
      2017-05-30), we made that worse by inadvertently changing that to the
      hash of the empty tree.
      
      Let's make the behavior consistent with files that have unstaged
      modifications (which applies to intent-to-add files, too) by showing
      all-zero values also for intent-to-add files.
      
      Accordingly, this patch adjusts the expectations set by the regression
      test introduced in feea6946 (diff-files: treat "i-t-a" files as
      "not-in-index", 2020-06-20).
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      85953a31
    • R
      send-email: restore --in-reply-to superseding behavior · f9f60d70
      Rafael Aquini 提交于
      git send-email --in-reply-to= fails to override In-Reply-To email headers,
      if they're present in the output of format-patch, even when explicitly
      told to do so by the option --no-thread, which breaks the contract of the
      command line switch option, per its man page.
      
      "
         --in-reply-to=<identifier>
             Make the first mail (or all the mails with --no-thread) appear as
             a reply to the given Message-Id, which avoids breaking threads to
             provide a new patch series.
      "
      
      This patch fixes the aformentioned issue, by bringing --in-reply-to's old
      overriding behavior back.
      
      The test was donated by Carlo Marcelo Arenas Belón.
      Signed-off-by: NRafael Aquini <aquini@redhat.com>
      Helped-by: NCarlo Marcelo Arenas Belón <carenas@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f9f60d70
  8. 26 6月, 2020 3 次提交
    • J
      fast-export: anonymize "master" refname · 8a494955
      Jeff King 提交于
      Running "fast-export --anonymize" will leave "refs/heads/master"
      untouched in the output, for two reasons:
      
        - it helped to have some known reference point between the original
          and anonymized repository
      
        - since it's historically the default branch name, it doesn't leak any
          information
      
      Now that we can ask fast-export to retain particular tokens, we have a
      much better tool for the first one (because it works for any ref, not
      just master).
      
      For the second, the notion of "default branch name" is likely to become
      configurable soon, at which point the name _does_ leak information.
      Let's drop this special case in preparation.
      
      Note that we have to adjust the test a bit, since it relied on using the
      name "master" in the anonymized repos. We could just use
      --anonymize-map=master to keep the same output, but then we wouldn't
      know if it works because of our hard-coded master or because of the
      explicit map.
      
      So let's flip the test a bit, and confirm that we anonymize "master",
      but keep "other" in the output.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8a494955
    • J
      fast-export: allow seeding the anonymized mapping · 65b5d9fa
      Jeff King 提交于
      After you anonymize a repository, it can be hard to find which commits
      correspond between the original and the result, and thus hard to
      reproduce commands that triggered bugs in the original.
      
      Let's make it possible to seed the anonymization map. This lets users
      either:
      
        - mark names to be retained as-is, if they don't consider them secret
          (in which case their original commands would just work)
      
        - map names to new values, which lets them adapt the reproduction
          recipe to the new names without revealing the originals
      
      The implementation is fairly straight-forward. We already store each
      anonymized token in a hashmap (so that the same token appearing twice is
      converted to the same result). We can just introduce a new "seed"
      hashmap which is consulted first.
      
      This does make a few more promises to the user about how we'll anonymize
      things (e.g., token-splitting pathnames). But it's unlikely that we'd
      want to change those rules, even if the actual anonymization of a single
      token changes. And it makes things much easier for the user, who can
      unblind only a directory name without having to specify each path within
      it.
      
      One alternative to this approach would be to anonymize as we see fit,
      and then dump the whole refname and pathname mappings to a file. This
      does work, but it's a bit awkward to use (you have to manually dig the
      items you care about out of the mapping).
      Helped-by: NEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      65b5d9fa
    • J
      tests: reference `seen` wherever `pu` was referenced · 6dca5dbf
      Johannes Schindelin 提交于
      As our test suite partially reflects how we work in the Git project, it
      is natural that the branch name `pu` was used in a couple places.
      
      Since that branch was renamed to `seen`, let's use the new name
      consistently.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6dca5dbf
  9. 25 6月, 2020 7 次提交
  10. 24 6月, 2020 6 次提交
    • D
      lib-submodule-update: pass 'test_must_fail' as an argument · 5b0ac09f
      Denton Liu 提交于
      When we run a test helper function in test_submodule_switch_common(), we
      sometimes specify a whole helper function as the $command. When we do
      this, in some test cases, we just mark the whole function with
      `test_must_fail`. However, it's possible that the helper function might
      fail earlier or later than expected due to an introduced bug. If this
      happens, then the test case will still report as passing but it should
      really be marked as failing since it didn't actually display the
      intended behaviour.
      
      Instead of invoking `test_must_fail $command`, pass the string
      "test_must_fail" as the second argument in case where the git command is
      expected to fail.
      
      When $command is a helper function, the parent function calling
      test_submodule_switch_common() is test_submodule_switch_func(). For all
      test_submodule_switch_func() invocations, increase the granularity of
      the argument test helper function by prefixing the git invocation which is
      meant to fail with the second argument like this:
      
      	$2 git checkout "$1"
      
      In the other cases, test_submodule_switch() and
      test_submodule_forced_switch(), instead of passing in the git command
      directly, wrap it using the git_test_func() and pass the git arguments
      using the global variable $gitcmd. Unfortunately, since closures aren't
      a thing in shell scripts, the global variable is necessary. Another
      unfortunate result is that the "git_test_func" will used as the test
      case name when $command is printed but it's worth it for the cleaner
      code.
      
      Finally, as an added bonus, `test_must_fail` will now only run on git
      commands.
      Signed-off-by: NDenton Liu <liu.denton@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5b0ac09f
    • J
      fast-export: use xmemdupz() for anonymizing oids · b897bf5f
      Jeff King 提交于
      Our anonymize_mem() function is careful to take a ptr/len pair to allow
      storing binary tokens like object ids, as well as partial strings (e.g.,
      just "foo" of "foo/bar"). But it duplicates the hash key using
      xstrdup()! That means that:
      
        - for a partial string, we'd store all bytes up to the NUL, even
          though we'd never look at anything past "len". This didn't produce
          wrong behavior, but was wasteful.
      
        - for a binary oid that doesn't contain a zero byte, we'd copy garbage
          bytes off the end of the array (though as long as nothing complained
          about reading uninitialized bytes, further reads would be limited by
          "len", and we'd produce the correct results)
      
        - for a binary oid that does contain a zero byte, we'd copy _fewer_
          bytes than intended into the hashmap struct. When we later try to
          look up a value, we'd access uninitialized memory and potentially
          falsely claim that a particular oid is not present.
      
      The most common reason to store an oid is an anonymized gitlink, but our
      test case doesn't have any gitlinks at all. So let's add one whose oid
      contains a NUL and is present at two different paths. ASan catches the
      memory error, but even without it we can detect the bug because the oid
      is not anonymized the same way for both paths.
      
      And of course the fix is to copy the correct number of bytes. We don't
      technically need the appended NUL from xmemdupz(), but it doesn't hurt
      as an extra protection against anybody treating it like a string (plus a
      future patch will push us more in that direction).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b897bf5f
    • J
      t9351: derive anonymized tree checks from original repo · b8c0689b
      Jeff King 提交于
      Our tests of the anonymized repo just hard-code the expected set of
      objects in the root and subdirectory trees. This makes them brittle to
      the test setup changing (e.g., adding new paths that need tested).
      
      Let's look at the original repo to compute our expected set of objects.
      Note that this isn't completely perfect (e.g., we still rely on there
      being only one tree in the root), but it does simplify later patches.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b8c0689b
    • J
      fmt-merge-msg: stop treating `master` specially · 489947ce
      Johannes Schindelin 提交于
      In the context of many projects renaming their primary branch names away
      from `master`, Git wants to stop treating the `master` branch specially.
      
      Let's start with `git fmt-merge-msg`.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      489947ce
    • C
      commit-reach: avoid is_descendant_of() shim · c1ea625f
      Carlo Marcelo Arenas Belón 提交于
      d91d6fbf (commit-reach: create repo_is_descendant_of(), 2020-06-17)
      adds a repository aware version of is_descendant_of() and a backward
      compatibility shim that is barely used.
      
      Update all callers to directly use the new repo_is_descendant_of()
      function instead; making the codebase simpler and pushing more
      the_repository references higher up the stack.
      Helped-by: NDerrick Stolee <dstolee@microsoft.com>
      Signed-off-by: NCarlo Marcelo Arenas Belón <carenas@gmail.com>
      Reviewed-by: NDerrick Stolee <dstolee@microsoft.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c1ea625f
    • B
      http-push: ensure unforced pushes fail when data would be lost · 64472d15
      brian m. carlson 提交于
      When we push using the DAV-based protocol, the client is the one that
      performs the ref updates and therefore makes the checks to see whether
      an unforced push should be allowed.  We make this check by determining
      if either (a) we lack the object file for the old value of the ref or
      (b) the new value of the ref is not newer than the old value, and in
      either case, reject the push.
      
      However, the ref_newer function, which performs this latter check, has
      an odd behavior due to the reuse of certain object flags.  Specifically,
      it will incorrectly return false in its first invocation and then
      correctly return true on a subsequent invocation.  This occurs because
      the object flags used by http-push.c are the same as those used by
      commit-reach.c, which implements ref_newer, and one piece of code
      misinterprets the flags set by the other.
      
      Note that this does not occur in all cases.  For example, if the example
      used in the tests is changed to use one repository instead of two and
      rewind the head to add a commit, the test passes and we correctly reject
      the push.  However, the example provided does trigger this behavior, and
      the code has been broken in this way since at least Git 2.0.0.
      
      To solve this problem, let's move the two sets of object flags so that
      they don't overlap, since we're clearly using them at the same time.
      The new set should not conflict with other usage because other users are
      either builtin code (which is not compiled into git http-push) or
      upload-pack (which we similarly do not use here).
      Reported-by: NMichael Ward <mward@smartsoftwareinc.com>
      Signed-off-by: NRené Scharfe <l.s.r@web.de>
      Signed-off-by: Nbrian m. carlson <sandals@crustytoothpaste.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      64472d15
  11. 23 6月, 2020 9 次提交
  12. 20 6月, 2020 5 次提交