1. 25 10月, 2013 1 次提交
  2. 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
  3. 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
  4. 31 8月, 2013 1 次提交
  5. 25 8月, 2013 1 次提交
  6. 07 8月, 2013 1 次提交
  7. 06 8月, 2013 2 次提交
  8. 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
  9. 16 7月, 2013 8 次提交
  10. 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
  11. 25 6月, 2013 4 次提交
  12. 24 6月, 2013 1 次提交
  13. 16 6月, 2013 1 次提交
  14. 13 6月, 2013 2 次提交
    • 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
    • J
      finish_copy_notes_for_rewrite(): Let caller provide commit message · 80a14665
      Johan Herland 提交于
      When copying notes for a rewritten object, the resulting notes commit
      would have the following hardcoded commit message:
      
        Notes added by 'git notes copy'
      
      This is obviously bogus when the notes rewriting is performed by
      'git commit --amend'.
      
      Therefore, let the caller specify an appropriate notes commit message
      instead of hardcoding it. The above message is used for 'git notes copy',
      but when calling finish_copy_notes_for_rewrite() from builtin/commit.c,
      we use the following message instead:
      
        Notes added by 'git commit --amend'
      
      Cc: Thomas Rast <trast@inf.ethz.ch>
      Signed-off-by: NJohan Herland <johan@herland.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      80a14665
  15. 12 6月, 2013 1 次提交
  16. 29 5月, 2013 1 次提交
  17. 19 4月, 2013 1 次提交
  18. 20 2月, 2013 1 次提交
    • B
      git-commit: only append a newline to -m mesg if necessary · a24a41ea
      Brandon Casey 提交于
      Currently, git will append two newlines to every message supplied via
      the -m switch.  The purpose of this is to allow -m to be supplied
      multiple times and have each supplied string become a paragraph in the
      resulting commit message.
      
      Normally, this does not cause a problem since any trailing newlines will
      be removed by the cleanup operation.  If cleanup=verbatim for example,
      then the trailing newlines will not be removed and will survive into the
      resulting commit message.
      
      Instead, let's ensure that the string supplied to -m is newline terminated,
      but only append a second newline when appending additional messages.
      
      Fixes the test in t7502.
      Signed-off-by: NBrandon Casey <drafnel@gmail.com>
      Reviewed-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a24a41ea
  19. 13 2月, 2013 2 次提交
  20. 27 1月, 2013 2 次提交
    • J
      logmsg_reencode: never return NULL · dd0d388c
      Jeff King 提交于
      The logmsg_reencode function will return the reencoded
      commit buffer, or NULL if reencoding failed or no reencoding
      was necessary. Since every caller then ends up checking for NULL
      and just using the commit's original buffer, anyway, we can
      be a bit more helpful and just return that buffer when we
      would have returned NULL.
      
      Since the resulting string may or may not need to be freed,
      we introduce a logmsg_free, which checks whether the buffer
      came from the commit object or not (callers either
      implemented the same check already, or kept two separate
      pointers, one to mark the buffer to be used, and one for the
      to-be-freed string).
      
      Pushing this logic into logmsg_* simplifies the callers, and
      will let future patches lazily load the commit buffer in a
      single place.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      dd0d388c
    • J
      commit: drop useless xstrdup of commit message · 200ebe36
      Jeff King 提交于
      When git-commit is asked to reuse a commit message via "-c",
      we call read_commit_message, which looks up the commit and
      hands back either the re-encoded result, or a copy of the
      original. We make a copy in the latter case so that the
      ownership semantics of the return value are clear (in either
      case, it can be freed).
      
      However, since we return a "const char *", and since the
      resulting buffer's lifetime is the same as that of the whole
      program, we never bother to free it at all.
      
      Let's just drop the copy. That saves us a copy in the common
      case. While it does mean we leak in the re-encode case, it
      doesn't matter, since we are relying on program exit to free
      the memory anyway.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      200ebe36
  21. 17 1月, 2013 1 次提交
    • J
      Allow custom "comment char" · eff80a9f
      Junio C Hamano 提交于
      Some users do want to write a line that begin with a pound sign, #,
      in their commit log message.  Many tracking system recognise
      a token of #<bugid> form, for example.
      
      The support we offer these use cases is not very friendly to the end
      users.  They have a choice between
      
       - Don't do it.  Avoid such a line by rewrapping or indenting; and
      
       - Use --cleanup=whitespace but remove all the hint lines we add.
      
      Give them a way to set a custom comment char, e.g.
      
          $ git -c core.commentchar="%" commit
      
      so that they do not have to do either of the two workarounds.
      
      [jc: although I started the topic, all the tests and documentation
      updates, many of the call sites of the new strbuf_add_commented_*()
      functions, and the change to git-submodule.sh scripted Porcelain are
      from Ralf.]
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NRalf Thielow <ralf.thielow@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      eff80a9f
  22. 15 1月, 2013 1 次提交
    • A
      hooks: Add function to check if a hook exists · 5a7da2dc
      Aaron Schrab 提交于
      Create find_hook() function to determine if a given hook exists and is
      executable.  If it is, the path to the script will be returned,
      otherwise NULL is returned.
      
      This encapsulates the tests that are used to check for the existence of
      a hook in one place, making it easier to modify those checks if that is
      found to be necessary.  This also makes it simple for places that can
      use a hook to check if a hook exists before doing, possibly lengthy,
      setup work which would be pointless if no such hook is present.
      
      The returned value is left as a static value from get_pathname() rather
      than a duplicate because it is anticipated that the return value will
      either be used as a boolean, immediately added to an argv_array list
      which would result in it being duplicated at that point, or used to
      actually run the command without much intervening work.  Callers which
      need to hold onto the returned value for a longer time are expected to
      duplicate the return value themselves.
      Signed-off-by: NAaron Schrab <aaron@schrab.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5a7da2dc
  23. 11 1月, 2013 1 次提交
  24. 16 11月, 2012 1 次提交
    • J
      ident: keep separate "explicit" flags for author and committer · d6991cee
      Jeff King 提交于
      We keep track of whether the user ident was given to us
      explicitly, or if we guessed at it from system parameters
      like username and hostname. However, we kept only a single
      variable. This covers the common cases (because the author
      and committer will usually come from the same explicit
      source), but can miss two cases:
      
        1. GIT_COMMITTER_* is set explicitly, but we fallback for
           GIT_AUTHOR. We claim the ident is explicit, even though
           the author is not.
      
        2. GIT_AUTHOR_* is set and we ask for author ident, but
           not committer ident. We will claim the ident is
           implicit, even though it is explicit.
      
      This patch uses two variables instead of one, updates both
      when we set the "fallback" values, and updates them
      individually when we read from the environment.
      
      Rather than keep user_ident_sufficiently_given as a
      compatibility wrapper, we update the only two callers to
      check the committer_ident, which matches their intent and
      what was happening already.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d6991cee