1. 27 1月, 2015 1 次提交
    • M
      commit: reword --author error message · 1044b1f6
      Michael J Gruber 提交于
      If an --author argument is specified but does not contain a '>' then git tries
      to find the argument within the existing authors; and gives the error
      message "No existing author found with '%s'" if there is no match.
      
      This is confusing for users who try to specify a valid complete author
      name.
      
      Rename the error message to make it clearer that the failure has two
      reasons in this case.
      
      (This codepath is touched only when we know already that the argument
      cannot be a completely wellformed author ident.)
      Signed-off-by: NMichael J Gruber <git@drmicha.warpmail.net>
      Helped-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1044b1f6
  2. 13 6月, 2014 1 次提交
    • J
      commit_tree: take a pointer/len pair rather than a const strbuf · 3ffefb54
      Jeff King 提交于
      While strbufs are pretty common throughout our code, it is
      more flexible for functions to take a pointer/len pair than
      a strbuf. It's easy to turn a strbuf into such a pair (by
      dereferencing its members), but less easy to go the other
      way (you can strbuf_attach, but that has implications about
      memory ownership).
      
      This patch teaches commit_tree (and its associated callers
      and sub-functions) to take such a pair for the commit
      message rather than a strbuf.  This makes passing the buffer
      around slightly more verbose, but means we can get rid of
      some dangerous strbuf_attach calls in the next patch.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3ffefb54
  3. 29 4月, 2014 1 次提交
    • J
      commit: do not complain of empty messages from -C · 076cbd63
      Jeff King 提交于
      When we pick another commit's message, we die() immediately
      if we find that it's empty and we are not going to run an
      editor (i.e., when running "-C" instead of "-c").  However,
      this check is redundant and harmful.
      
      It's redundant because we will already notice the empty
      message later, after we would have run the editor, and die
      there (just as we would for a regular, not "-C" case, where
      the user provided an empty message in the editor).
      
      It's harmful for a few reasons:
      
        1. It does not respect --allow-empty-message. As a result,
           a "git rebase -i" cannot "pick" such a commit. So you
           cannot even go back in time to fix it with a "reword"
           or "edit" instruction.
      
        2. It does not take into account other ways besides the
           editor to modify the message. For example, "git commit
           -C empty-commit -m foo" could take the author
           information from empty-commit, but add a message to it.
           There's more to do to make that work correctly (and
           right now we explicitly forbid "-C with -m"), but this
           removes one roadblock.
      
        3. The existing check is not enough to prevent segfaults.
           We try to find the "\n\n" header/body boundary in the
           commit. If it is at the end of the string (i.e., no
           body), _or_ if we cannot find it at all (i.e., a
           truncated commit object), we consider the message
           empty. With "-C", that's OK; we die in either case. But
           with "-c", we continue on, and in the case of a
           truncated commit may end up dereferencing NULL+2.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      076cbd63
  4. 08 4月, 2014 1 次提交
    • J
      commit -m: commit staged submodules regardless of ignore config · c215d3d2
      Jens Lehmann 提交于
      The previous commit fixed the problem that the staged but that ignored
      submodules did not show up in the status output of the commit command and
      weren't committed afterwards either. But when commit doesn't generate the
      status output (e.g. when used in a script with '-m') the ignored submodule
      will still not be committed. This is because in that case a different code
      path is taken which calls index_differs_from() instead of calling the
      wt_status functions.
      
      Fix that by calling index_differs_from() from builtin/commit.c with a
      diff_options argument value that tells it not ignore any submodule changes
      unless the '--ignore-submodules' option is used. Even though this option
      isn't yet implemented for cmd_commit() but only for cmd_status() this
      prepares cmd_commit() to correctly handle the '--ignore-submodules' option
      later. As status and commit share the same ignore_submodule_arg variable
      this makes the code more robust against accidental breakage and documents
      how to correctly call index_differs_from().
      
      Change the expected result of the test documenting this problem from
      failure to success.
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c215d3d2
  5. 01 4月, 2014 1 次提交
  6. 25 3月, 2014 1 次提交
    • J
      parse-options: multi-word argh should use dash to separate words · e703d711
      Junio C Hamano 提交于
      "When you need to use space, use dash" is a strange way to say that
      you must not use a space.  Because it is more common for the command
      line descriptions to use dashed-multi-words, you do not even want to
      use spaces in these places.  Rephrase the documentation to avoid
      this strangeness.
      
      Fix a few existing multi-word argument help strings, i.e.
      
       - GPG key-ids given to -S/--gpg-sign are "key-id";
       - Refs used for storing notes are "notes-ref"; and
       - Expiry timestamps given to --expire are "expiry-date".
      
      and update the corresponding documentation pages.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e703d711
  7. 19 3月, 2014 1 次提交
  8. 26 2月, 2014 1 次提交
  9. 25 2月, 2014 2 次提交
  10. 01 2月, 2014 1 次提交
  11. 06 12月, 2013 2 次提交
    • J
      commit -v: strip diffs and submodule shortlogs from the commit message · 1a72cfd7
      Jens Lehmann 提交于
      When using the '-v' option of "git commit" the diff added to the commit
      message temporarily for editing is stripped off after the user exited the
      editor by searching for "\ndiff --git " and truncating the commmit message
      there if it is found.
      
      But this approach has two problems:
      
      - when the commit message itself contains a line starting with
        "diff --git" it will be truncated there prematurely; and
      
      - when the "diff.submodule" setting is set to "log", the diff may
        start with "Submodule <hash1>..<hash2>", which will be left in
        the commit message while it shouldn't.
      
      Fix that by introducing a special scissor separator line starting with the
      comment character ('#' or the core.commentChar config if set) followed by
      two lines describing what it is for. The scissor line - which will not be
      translated - is used to reliably detect the start of the diff so it can be
      chopped off from the commit message, no matter what the user enters there.
      
      Turn a known test failure fixed by this change into a successful test;
      also add one for a diff starting with a submodule log and another one for
      proper handling of the comment char.
      Reported-by: NAri Pollak <ari@debian.org>
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1a72cfd7
    • C
      replace {pre,suf}fixcmp() with {starts,ends}_with() · 59556548
      Christian Couder 提交于
      Leaving only the function definitions and declarations so that any
      new topic in flight can still make use of the old functions, replace
      existing uses of the prefixcmp() and suffixcmp() with new API
      functions.
      
      The change can be recreated by mechanically applying this:
      
          $ git grep -l -e prefixcmp -e suffixcmp -- \*.c |
            grep -v strbuf\\.c |
            xargs perl -pi -e '
              s|!prefixcmp\(|starts_with\(|g;
              s|prefixcmp\(|!starts_with\(|g;
              s|!suffixcmp\(|ends_with\(|g;
              s|suffixcmp\(|!ends_with\(|g;
            '
      
      on the result of preparatory changes in this series.
      Signed-off-by: NChristian Couder <chriscool@tuxfamily.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      59556548
  12. 25 10月, 2013 1 次提交
  13. 13 9月, 2013 3 次提交
    • M
      commit: disable status hints when writing to COMMIT_EDITMSG · ea9882bf
      Matthieu Moy 提交于
      This turns the template COMMIT_EDITMSG from e.g
      
        # [...]
        # Changes to be committed:
        #   (use "git reset HEAD <file>..." to unstage)
        #
        #	modified:   builtin/commit.c
        #
        # Untracked files:
        #   (use "git add <file>..." to include in what will be committed)
        #
        #	t/foo
        #
      
      to
      
        # [...]
        # Changes to be committed:
        #	modified:   builtin/commit.c
        #
        # Untracked files:
        #	t/foo
        #
      
      Most status hints were written to be accurate when running "git status"
      before running a commit. Many of them are not applicable when the commit
      has already been started, and should not be shown in COMMIT_EDITMSG. The
      most obvious are hints advising to run "git commit",
      "git rebase/am/cherry-pick --continue", which do not make sense when the
      command has already been run.
      
      Other messages become slightly inaccurate (e.g. hint to use "git add" to
      add untracked files), as the suggested commands are not immediately
      applicable during the editing of COMMIT_EDITMSG, but would be applicable
      if the commit is aborted. These messages are both potentially helpful and
      slightly misleading. This patch chose to remove them too, to avoid
      introducing too much complexity in the status code.
      Signed-off-by: NMatthieu Moy <Matthieu.Moy@imag.fr>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ea9882bf
    • M
      wt-status: turn advice_status_hints into a field of wt_status · 6a964f57
      Matthieu Moy 提交于
      No behavior change in this patch, but this makes the display of status
      hints more flexible as they can be enabled or disabled for individual
      calls to commit.c:run_status().
      Signed-off-by: NMatthieu Moy <Matthieu.Moy@imag.fr>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6a964f57
    • M
      commit: factor status configuration is a helper function · 5c25dfaa
      Matthieu Moy 提交于
      cmd_commit and cmd_status use very similar code to initialize the
      wt_status structure. Factor this code into a function to ensure future
      changes will keep both versions consistent.
      Signed-off-by: NMatthieu Moy <Matthieu.Moy@imag.fr>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5c25dfaa
  14. 07 9月, 2013 1 次提交
    • M
      status: disable display of '#' comment prefix by default · 2556b996
      Matthieu Moy 提交于
      Historically, "git status" needed to prefix each output line with '#' so
      that the output could be added as comment to the commit message. This
      prefix comment has no real purpose when "git status" is ran from the
      command-line, and this may distract users from the real content.
      
      Disable this prefix comment by default, and make it re-activable for
      users needing backward compatibility with status.displayCommentPrefix.
      
      Obviously, "git commit" ignores status.displayCommentPrefix and keeps the
      comment unconditionnaly when writing to COMMIT_EDITMSG (but not when
      writing to stdout for an error message or with --dry-run).
      Signed-off-by: NMatthieu Moy <Matthieu.Moy@imag.fr>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2556b996
  15. 31 8月, 2013 1 次提交
  16. 25 8月, 2013 1 次提交
  17. 07 8月, 2013 1 次提交
  18. 06 8月, 2013 2 次提交
  19. 29 7月, 2013 1 次提交
    • J
      commit: tweak empty cherry pick advice for sequencer · c17592a7
      Jeff King 提交于
      When we refuse to make an empty commit, we check whether we
      are in a cherry-pick in order to give better advice on how
      to proceed. We instruct the user to repeat the commit with
      "--allow-empty" to force the commit, or to use "git reset"
      to skip it and abort the cherry-pick.
      
      In the case of a single cherry-pick, the distinction between
      skipping and aborting is not important, as there is no more
      work to be done afterwards.  When we are using the sequencer
      to cherry pick a series of commits, though, the instruction
      is confusing: does it skip this commit, or does it abort the
      rest of the cherry-pick?
      
      It does skip, after which the user can continue the
      cherry-pick. This is the right thing to be advising the user
      to do, but let's make it more clear what will happen, both
      by using the word "skip", and by mentioning that the rest of
      the sequence can be continued via "cherry-pick --continue"
      (whether we skip or take the commit).
      Noticed-by: NRamkumar Ramachandra <artagnon@gmail.com>
      Helped-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c17592a7
  20. 16 7月, 2013 8 次提交
  21. 10 7月, 2013 1 次提交
    • N
      Convert "struct cache_entry *" to "const ..." wherever possible · 9c5e6c80
      Nguyễn Thái Ngọc Duy 提交于
      I attempted to make index_state->cache[] a "const struct cache_entry **"
      to find out how existing entries in index are modified and where. The
      question I have is what do we do if we really need to keep track of on-disk
      changes in the index. The result is
      
       - diff-lib.c: setting CE_UPTODATE
      
       - name-hash.c: setting CE_HASHED
      
       - preload-index.c, read-cache.c, unpack-trees.c and
         builtin/update-index: obvious
      
       - entry.c: write_entry() may refresh the checked out entry via
         fill_stat_cache_info(). This causes "non-const struct cache_entry
         *" in builtin/apply.c, builtin/checkout-index.c and
         builtin/checkout.c
      
       - builtin/ls-files.c: --with-tree changes stagemask and may set
         CE_UPDATE
      
      Of these, write_entry() and its call sites are probably most
      interesting because it modifies on-disk info. But this is stat info
      and can be retrieved via refresh, at least for porcelain
      commands. Other just uses ce_flags for local purposes.
      
      So, keeping track of "dirty" entries is just a matter of setting a
      flag in index modification functions exposed by read-cache.c. Except
      unpack-trees, the rest of the code base does not do anything funny
      behind read-cache's back.
      
      The actual patch is less valueable than the summary above. But if
      anyone wants to re-identify the above sites. Applying this patch, then
      this:
      
          diff --git a/cache.h b/cache.h
          index 430d021..1692891 100644
          --- a/cache.h
          +++ b/cache.h
          @@ -267,7 +267,7 @@ static inline unsigned int canon_mode(unsigned int mode)
           #define cache_entry_size(len) (offsetof(struct cache_entry,name) + (len) + 1)
      
           struct index_state {
          -	struct cache_entry **cache;
          +	const struct cache_entry **cache;
           	unsigned int version;
           	unsigned int cache_nr, cache_alloc, cache_changed;
           	struct string_list *resolve_undo;
      
      will help quickly identify them without bogus warnings.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9c5e6c80
  22. 25 6月, 2013 4 次提交
  23. 24 6月, 2013 1 次提交
  24. 16 6月, 2013 1 次提交
  25. 13 6月, 2013 1 次提交
    • J
      Move copy_note_for_rewrite + friends from builtin/notes.c to notes-utils.c · 49c24704
      Johan Herland 提交于
      This is a pure code movement of the machinery for copying notes to
      rewritten objects. This code was located in builtin/notes.c for
      historical reasons. In order to make it available to builtin/commit.c
      it was declared in builtin.h. This was more of an accident of history
      than a concious design, and we now want to make this machinery more
      widely available.
      
      Hence, this patch moves the code into the new notes-utils.[hc] files
      which are included into libgit.a. Except for adjusting #includes
      accordingly, this patch merely moves the relevant functions verbatim
      into the new files.
      
      Cc: Thomas Rast <trast@inf.ethz.ch>
      Signed-off-by: NJohan Herland <johan@herland.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      49c24704