1. 23 3月, 2016 1 次提交
    • S
      submodule: fix regression for deinit without submodules · 84ba959b
      Stefan Beller 提交于
      Per Cederqvist wrote:
      > It used to be possible to run
      >
      >    git submodule deinit -f .
      >
      > to remove any submodules, no matter how many submodules you had.  That
      > is no longer possible in projects that don't have any submodules at
      > all.  The command will fail with:
      >
      >     error: pathspec '.' did not match any file(s) known to git.
      
      This regression was introduced in 74703a1e (submodule: rewrite
      `module_list` shell function in C, 2015-09-02), as we changed the
      order of checking in new module listing to first check whether it is
      a gitlin before feeding it to match_pathspec().  It used to be that
      a pathspec that does not match any path were diagnosed as an error,
      but the new code complains for a pathspec that does not match any
      submodule path.
      
      Arguably the new behaviour may give us a better diagnosis, but that
      is inconsistent with the suggestion "deinit" gives, and also this
      was an unintended accident.  The new behaviour hopefully can be
      redesigned and implemented better in future releases, but for now,
      switch these two checks to restore the same behavior as before.  In
      an empty repository, giving the pathspec '.' will still get the same
      "did not match" error, but that is the same bug we had before 1.7.0.
      Reported-by: NPer Cederqvist <cederp@opera.com>
      Signed-off-by: NStefan Beller <sbeller@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      84ba959b
  2. 22 3月, 2016 1 次提交
    • S
      commit: do not lose SQUASH_MSG contents · b64c1e07
      Sven Strickroth 提交于
      When concluding a conflicted "git merge --squash", the command
      failed to read SQUASH_MSG that was prepared by "git merge", and
      showed only the "# Conflicts:" list of conflicted paths.
      
      Place the contents from SQUASH_MSG at the beginning, just like we
      show the commit log skeleton first when concluding a normal merge,
      and then show the "# Conflicts:" list, to help the user write the
      log message for the resulting commit.
      
      Test by Junio C Hamano <gitster@pobox.com>.
      Signed-off-by: NSven Strickroth <sven@cs-ware.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b64c1e07
  3. 17 3月, 2016 2 次提交
    • J
      list-objects: pass full pathname to callbacks · 2824e184
      Jeff King 提交于
      When we find a blob at "a/b/c", we currently pass this to
      our show_object_fn callbacks as two components: "a/b/" and
      "c". Callbacks which want the full value then call
      path_name(), which concatenates the two. But this is an
      inefficient interface; the path is a strbuf, and we could
      simply append "c" to it temporarily, then roll back the
      length, without creating a new copy.
      
      So we could improve this by teaching the callsites of
      path_name() this trick (and there are only 3). But we can
      also notice that no callback actually cares about the
      broken-down representation, and simply pass each callback
      the full path "a/b/c" as a string. The callback code becomes
      even simpler, then, as we do not have to worry about freeing
      an allocated buffer, nor rolling back our modification to
      the strbuf.
      
      This is theoretically less efficient, as some callbacks
      would not bother to format the final path component. But in
      practice this is not measurable. Since we use the same
      strbuf over and over, our work to grow it is amortized, and
      we really only pay to memcpy a few bytes.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2824e184
    • J
      list-objects: drop name_path entirely · dc06dc88
      Jeff King 提交于
      In the previous commit, we left name_path as a thin wrapper
      around a strbuf. This patch drops it entirely. As a result,
      every show_object_fn callback needs to be adjusted. However,
      none of their code needs to be changed at all, because the
      only use was to pass it to path_name(), which now handles
      the bare strbuf.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      dc06dc88
  4. 08 3月, 2016 1 次提交
    • J
      grep: turn off gitlink detection for --no-index · 85975c0c
      Jeff King 提交于
      If we are running "git grep --no-index" outside of a git
      repository, we behave roughly like "grep -r", examining all
      files in the current directory and its subdirectories.
      However, because we use fill_directory() to do the
      recursion, it will skip over any directories which look like
      sub-repositories.
      
      For a normal git operation (like "git grep" in a repository)
      this makes sense; we do not want to cross the boundary out
      of our current repository into a submodule. But for
      "--no-index" without a repository, we should look at all
      files, including embedded repositories.
      
      There is one exception, though: we probably should _not_
      descend into ".git" directories. Doing so is inefficient and
      unlikely to turn up useful hits.
      
      This patch drops our use of dir.c's gitlink-detection, but
      we do still avoid ".git". That makes us more like tools such
      as "ack" or "ag", which also know to avoid cruft in .git.
      
      As a bonus, this also drops our usage of the ref code
      when we are outside of a repository, making the transition
      to pluggable ref backends cleaner.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      85975c0c
  5. 07 3月, 2016 1 次提交
    • J
      setup: set startup_info->have_repository more reliably · f1c126bd
      Jeff King 提交于
      When setup_git_directory() is called, we set a flag in
      startup_info to indicate we have a repository. But there are
      a few other mechanisms by which we might set up a repo:
      
        1. When creating a new repository via init_db(), we
           transition from no-repo to being in a repo. We should
           tweak this flag at that moment.
      
        2. In enter_repo(), a stricter form of
           setup_git_directory() used by server-side programs, we
           check the repository format config. After doing so, we
           know we're in a repository, and can set the flag.
      
      With these changes, library code can now reliably tell
      whether we are in a repository and act accordingly. We'll
      leave the "prefix" field as NULL, which is what happens when
      setup_git_directory() finds there is no prefix.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f1c126bd
  6. 04 3月, 2016 2 次提交
    • J
      index-pack: add a helper function to derive .idx/.keep filename · bfee614a
      Junio C Hamano 提交于
      These are automatically named by replacing .pack suffix in the
      name of the packfile.  Add a small helper to do so, as I'll be
      adding another one soonish.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      bfee614a
    • J
      index-pack: correct --keep[=<msg>] · 0e94242d
      Junio C Hamano 提交于
      When 592ce208 (index-pack: use strip_suffix to avoid magic numbers,
      2014-06-30) refactored the code to derive names of .idx and .keep
      files from the name of .pack file, a copy-and-paste typo crept in,
      mistakingly attempting to create and store the keep message file in
      the .idx file we just created, instead of .keep file.
      
      As we create the .keep file with O_CREAT|O_EXCL, and we do so after
      we write the .idx file, we luckily do not clobber the .idx file, but
      because we deliberately ignored EEXIST when creating .keep file
      (which is justifiable because only the existence of .keep file
      matters), nobody noticed this mistake so far.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0e94242d
  7. 02 3月, 2016 1 次提交
  8. 01 3月, 2016 3 次提交
  9. 29 2月, 2016 1 次提交
    • J
      config: fail if --get-urlmatch finds no value · 27b30be6
      John Keeping 提交于
      The --get, --get-all and --get-regexp options to git-config exit with
      status 1 if the key is not found but --get-urlmatch succeeds in this
      case.
      
      Change --get-urlmatch to behave in the same way as the other --get*
      options so that all four are consistent.  --get-color is a special case
      because it accepts a default value to return and so should not return an
      error if the key is not found.
      
      Also clarify this behaviour in the documentation.
      Signed-off-by: NJohn Keeping <john@keeping.me.uk>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      27b30be6
  10. 26 2月, 2016 3 次提交
    • J
      nth_packed_object_offset: bounds-check extended offset · 47fe3f6e
      Jeff King 提交于
      If a pack .idx file has a corrupted offset for an object, we
      may try to access an offset in the .idx or .pack file that
      is larger than the file's size.  For the .pack case, we have
      use_pack() to protect us, which realizes the access is out
      of bounds. But if the corrupted value asks us to look in the
      .idx file's secondary 64-bit offset table, we blindly add it
      to the mmap'd index data and access arbitrary memory.
      
      We can fix this with a simple bounds-check compared to the
      size we found when we opened the .idx file.
      
      Note that there's similar code in index-pack that is
      triggered only during "index-pack --verify". To support
      both, we pull the bounds-check into a separate function,
      which dies when it sees a corrupted file.
      
      It would be nice if we could return an error, so that the
      pack code could try to find a good copy of the object
      elsewhere. Currently nth_packed_object_offset doesn't have
      any way to return an error, but it could probably use "0" as
      a sentinel value (since no object can start there). This is
      the minimal fix, and we can improve the resilience later on
      top.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      47fe3f6e
    • J
      git config: report when trying to modify a non-existing repo config · 638fa623
      Johannes Schindelin 提交于
      It is a pilot error to call `git config section.key value` outside of
      any Git worktree. The message
      
      	error: could not lock config file .git/config: No such file or
      	directory
      
      is not very helpful in that situation, though. Let's print a helpful
      message instead.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      638fa623
    • M
      push: remove "push.default is unset" warning message · 2f275207
      Matthieu Moy 提交于
      The warning was important before the 2.0 transition, and remained
      important for a while after, so that new users get push.default
      explicitly in their configuration and do not experience inconsistent
      behavior if they ever used an older version of Git.
      
      The warning has been there since version 1.8.0 (Oct 2012), hence we can
      expect the vast majority of current Git users to have been exposed to
      it, and most of them have already set push.default explicitly. The
      switch from 'matching' to 'simple' was planned for 2.0 (May 2014), but
      actually happened only for 2.3 (Feb 2015).
      
      Today, the warning is mostly seen by beginners, who have not set their
      push.default configuration (yet). For many of them, the warning is
      confusing because it talks about concepts that they have not learned and
      asks them a choice that they are not able to make yet. See for example
      
        http://stackoverflow.com/questions/13148066/warning-push-default-is-unset-its-implicit-value-is-changing-in-git-2-0
      
      (1260 votes for the question, 1824 for the answer as of writing)
      
      Remove the warning completely to avoid disturbing beginners. People who
      still occasionally use an older version of Git will be exposed to the
      warning through this old version.
      
      Eventually, versions of Git without the warning will be deployed enough
      and tutorials will not need to advise setting push.default anymore.
      Signed-off-by: NMatthieu Moy <Matthieu.Moy@imag.fr>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2f275207
  11. 25 2月, 2016 1 次提交
  12. 23 2月, 2016 17 次提交
  13. 20 2月, 2016 1 次提交
    • J
      reflog_expire_cfg: NUL-terminate pattern field · c3a700fb
      Jeff King 提交于
      You can tweak the reflog expiration for a particular subset
      of refs by configuring gc.foo.reflogexpire. We keep a linked
      list of reflog_expire_cfg structs, each of which holds the
      pattern and a "len" field for the length of the pattern. The
      pattern itself is _not_ NUL-terminated.
      
      However, we feed the pattern directly to wildmatch(), which
      expects a NUL-terminated string, meaning it may keep reading
      random junk after our struct.
      
      We can fix this by allocating an extra byte for the NUL
      (which is already zero because we use xcalloc). Let's also
      drop the misleading "len" field, which is no longer
      necessary. The existing use of "len" can be converted to use
      strncmp().
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c3a700fb
  14. 18 2月, 2016 1 次提交
    • J
      am -i: fix "v"iew · 708b8cc9
      Junio C Hamano 提交于
      The 'v'iew subcommand of the interactive mode of "git am -i" was
      broken by the rewrite to C we did at around 2.6.0 timeframe at
      7ff26832 (builtin-am: implement -i/--interactive, 2015-08-04); we
      used to spawn the pager via the shell, accepting things like
      
      	PAGER='less -S'
      
      in the environment, but the rewrite forgot and tried to directly
      spawn a command whose name is the entire string.
      
      The previous refactoring of the new helper function makes it easier
      for us to do the right thing.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      708b8cc9
  15. 17 2月, 2016 3 次提交
    • T
      remote: use remote_is_configured() for add and rename · a31eeae2
      Thomas Gummerer 提交于
      Both remote add and remote rename use a slightly different hand-rolled
      check if the remote exits.  The hand-rolled check may have some subtle
      cases in which it might fail to detect when a remote already exists.
      One such case was fixed in fb86e32d ("git remote: allow adding remotes
      agreeing with url.<...>.insteadOf").  Another case is when a remote is
      configured as follows:
      
        [remote "foo"]
          vcs = bar
      
      If we try to run `git remote add foo bar` with the above remote
      configuration, git segfaults.  This change fixes it.
      
      In addition, git remote rename $existing foo with the configuration for
      foo as above silently succeeds, even though foo already exists,
      modifying its configuration.  With this patch it fails with "remote foo
      already exists".
      Signed-off-by: NThomas Gummerer <t.gummerer@gmail.com>
      Reviewed-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a31eeae2
    • T
      remote: actually check if remote exits · cc8e538d
      Thomas Gummerer 提交于
      When converting the git remote command to a builtin in 211c89 ("Make
      git-remote a builtin"), a few calls to check if a remote exists were
      converted from:
             if (!exists $remote->{$name}) {
             	  [...]
      to:
             remote = remote_get(argv[1]);
             if (!remote)
                [...]
      
      The new check is not quite correct, because remote_get() never returns
      NULL if a name is given.  This leaves us with the somewhat cryptic error
      message "error: Could not remove config section 'remote.test'", if we
      are trying to remove a remote that does not exist, or a similar error if
      we try to rename a remote.
      
      Use the remote_is_configured() function to check whether the remote
      actually exists, and die with a more sensible error message ("No such
      remote: $remotename") instead if it doesn't.
      Signed-off-by: NThomas Gummerer <t.gummerer@gmail.com>
      Reviewed-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cc8e538d
    • T
      remote: simplify remote_is_configured() · 674468b3
      Thomas Gummerer 提交于
      The remote_is_configured() function allows checking whether a remote
      exists or not.  The function however only works if remote_get() wasn't
      called before calling it.  In addition, it only checks the configuration
      for remotes, but not remotes or branches files.
      
      Make use of the origin member of struct remote instead, which indicates
      where the remote comes from.  It will be set to some value if the remote
      is configured in any file in the repository, but is initialized to 0 if
      the remote is only created in make_remote().
      Signed-off-by: NThomas Gummerer <t.gummerer@gmail.com>
      Reviewed-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      674468b3
  16. 16 2月, 2016 1 次提交