1. 31 3月, 2012 2 次提交
  2. 12 3月, 2012 1 次提交
    • J
      commit: pass author/committer info to hooks · 7dfe8ad6
      Junio C Hamano 提交于
      When lying the author name via GIT_AUTHOR_NAME environment variable
      to "git commit", the hooks run by the command saw it and could act
      on the name that will be recorded in the final commit. When the user
      uses the "--author" option from the command line, the command should
      give the same information to the hook, and back when "git command"
      was a scripted Porcelain, it did set the environment variable and
      hooks can learn the author name from it.
      
      However, when the command was reimplemented in C, the rewritten code
      was not very faithful to the original, and hooks stopped getting the
      authorship information given with "--author".  Fix this by exporting
      the necessary environment variables.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7dfe8ad6
  3. 08 2月, 2012 1 次提交
  4. 04 2月, 2012 1 次提交
    • J
      parse_date(): '@' prefix forces git-timestamp · 2c733fb2
      Junio C Hamano 提交于
      The only place that the issue this series addresses was observed
      where we read "cat-file commit" output and put it in GIT_AUTHOR_DATE
      in order to replay a commit with an ancient timestamp.
      
      With the previous patch alone, "git commit --date='20100917 +0900'"
      can be misinterpreted to mean an ancient timestamp, not September in
      year 2010.  Guard this codepath by requring an extra '@' in front of
      the raw git timestamp on the parsing side. This of course needs to
      be compensated by updating get_author_ident_from_commit and the code
      for "git commit --amend" to prepend '@' to the string read from the
      existing commit in the GIT_AUTHOR_DATE environment variable.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2c733fb2
  5. 02 2月, 2012 1 次提交
  6. 06 1月, 2012 1 次提交
  7. 21 12月, 2011 1 次提交
  8. 16 12月, 2011 1 次提交
  9. 14 12月, 2011 1 次提交
  10. 09 12月, 2011 1 次提交
    • J
      commit: honour --no-edit · ca1ba201
      Junio C Hamano 提交于
      After making fixes to the contents to be committed, it is not unusual to
      update the current commit without rewording the message. Idioms to tell
      "commit --amend" that we do not need an editor have been:
      
          $ EDITOR=: git commit --amend
          $ git commit --amend -C HEAD
      
      but that was only because a more natural "--no-edit" option in
      
          $ git commit --amend --no-edit
      
      was not honoured.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ca1ba201
  11. 07 12月, 2011 2 次提交
    • T
      commit: write cache-tree data when writing index anyway · 11c8a74a
      Thomas Rast 提交于
      In prepare_index(), we refresh the index, and then write it to disk if
      this changed the index data.  After running hooks we re-read the index
      and compute the root tree sha1 with the cache-tree machinery.
      
      This gives us a mostly free opportunity to write up-to-date cache-tree
      data: we can compute it in prepare_index() immediately before writing
      the index to disk.
      
      If we do this, we were going to write the index anyway, and the later
      cache-tree update has no further work to do.  If we don't do it, we
      don't do any extra work, though we still don't have have cache-tree
      data after the commit.
      
      The only case that suffers badly is when the pre-commit hook changes
      many trees in the index.  I'm writing this off as highly unusual.
      Signed-off-by: NThomas Rast <trast@student.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      11c8a74a
    • T
      Refactor cache_tree_update idiom from commit · 996277c5
      Thomas Rast 提交于
      We'll need to safely create or update the cache-tree data of the_index
      from other places.  While at it, give it an argument that lets us
      silence the messages produced by unmerged entries (which prevent it
      from working).
      Signed-off-by: NThomas Rast <trast@student.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      996277c5
  12. 06 12月, 2011 1 次提交
    • N
      Copy resolve_ref() return value for longer use · d5a35c11
      Nguyễn Thái Ngọc Duy 提交于
      resolve_ref() may return a pointer to a static buffer. Callers that
      use this value longer than a couple of statements should copy the
      value to avoid some hidden resolve_ref() call that may change the
      static buffer's value.
      
      The bug found by Tony Wang <wwwjfy@gmail.com> in builtin/merge.c
      demonstrates this. The first call is in cmd_merge()
      
      branch = resolve_ref("HEAD", head_sha1, 0, &flag);
      
      Then deep in lookup_commit_or_die() a few lines after, resolve_ref()
      may be called again and destroy "branch".
      
      lookup_commit_or_die
       lookup_commit_reference
        lookup_commit_reference_gently
         parse_object
          lookup_replace_object
           do_lookup_replace_object
            prepare_replace_object
             for_each_replace_ref
              do_for_each_ref
               get_loose_refs
                get_ref_dir
                 get_ref_dir
                  resolve_ref
      
      All call sites are checked and made sure that xstrdup() is called if
      the value should be saved.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d5a35c11
  13. 23 11月, 2011 1 次提交
    • J
      revert: write REVERT_HEAD pseudoref during conflicted revert · 82433cdf
      Jonathan Nieder 提交于
      When conflicts are encountered while reverting a commit, it can be
      handy to have the name of that commit easily available.  For example,
      to produce a copy of the patch to refer to while resolving conflicts:
      
      	$ git revert 2eceb2a8
      	error: could not revert 2eceb2a8... awesome, buggy feature
      	$ git show -R REVERT_HEAD >the-patch
      	$ edit $(git diff --name-only)
      
      Set a REVERT_HEAD pseudoref when "git revert" does not make a commit,
      for cases like this.  This also makes it possible for scripts to
      distinguish between a revert that encountered conflicts and other
      sources of an unmerged index.
      
      After successfully committing, resetting with "git reset", or moving
      to another commit with "git checkout" or "git reset", the pseudoref is
      no longer useful, so remove it.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      82433cdf
  14. 13 11月, 2011 1 次提交
    • J
      commit: teach --gpg-sign option · ba3c69a9
      Junio C Hamano 提交于
      This uses the gpg-interface.[ch] to allow signing the commit, i.e.
      
          $ git commit --gpg-sign -m foo
          You need a passphrase to unlock the secret key for
          user: "Junio C Hamano <gitster@pobox.com>"
          4096-bit RSA key, ID 96AFE6CB, created 2011-10-03 (main key ID 713660A7)
      
          [master 8457d13] foo
           1 files changed, 1 insertions(+), 0 deletions(-)
      
      The lines of GPG detached signature are placed in a new multi-line header
      field, instead of tucking the signature block at the end of the commit log
      message text (similar to how signed tag is done), for multiple reasons:
      
       - The signature won't clutter output from "git log" and friends if it is
         in the extra header. If we place it at the end of the log message, we
         would need to teach "git log" and friends to strip the signature block
         with an option.
      
       - Teaching new versions of "git log" and "gitk" to optionally verify and
         show signatures is cleaner if we structurally know where the signature
         block is (instead of scanning in the commit log message).
      
       - The signature needs to be stripped upon various commit rewriting
         operations, e.g. rebase, filter-branch, etc. They all already ignore
         unknown headers, but if we place signature in the log message, all of
         these tools (and third-party tools) also need to learn how a signature
         block would look like.
      
       - When we added the optional encoding header, all the tools (both in tree
         and third-party) that acts on the raw commit object should have been
         fixed to ignore headers they do not understand, so it is not like that
         new header would be more likely to break than extra text in the commit.
      
      A commit made with the above sample sequence would look like this:
      
          $ git cat-file commit HEAD
          tree 3cd71d90e3db4136e5260ab54599791c4f883b9d
          parent b87755351a47b09cb27d6913e6e0e17e6254a4d4
          author Junio C Hamano <gitster@pobox.com> 1317862251 -0700
          committer Junio C Hamano <gitster@pobox.com> 1317862251 -0700
          gpgsig -----BEGIN PGP SIGNATURE-----
           Version: GnuPG v1.4.10 (GNU/Linux)
      
           iQIcBAABAgAGBQJOjPtrAAoJELC16IaWr+bL4TMP/RSe2Y/jYnCkds9unO5JEnfG
           ...
           =dt98
           -----END PGP SIGNATURE-----
      
          foo
      
      but "git log" (unless you ask for it with --pretty=raw) output is not
      cluttered with the signature information.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ba3c69a9
  15. 10 11月, 2011 2 次提交
    • J
      commit: teach --amend to carry forward extra headers · ed7a42a0
      Junio C Hamano 提交于
      After running "git pull $there for-linus" to merge a signed tag, the
      integrator may need to amend the resulting merge commit to fix typoes
      in it. Teach --amend option to read the existing extra headers, and
      carry them forward.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ed7a42a0
    • J
      commit: copy merged signed tags to headers of merge commit · 5231c633
      Junio C Hamano 提交于
      Now MERGE_HEAD records the tag objects without peeling, we could record
      the result of manual conflict resolution via "git commit" without losing
      the tag information. Introduce a new "mergetag" multi-line header field to
      the commit object, and use it to store the entire contents of each signed
      tag merged.
      
      A commit header that has a multi-line payload begins with the header tag
      (e.g. "mergetag" in this case), SP, the first line of payload, LF, and all
      the remaining lines have a SP inserted at the beginning.
      
      In hindsight, it would have been better to make "merge --continue" as the
      way to continue from such an interrupted merge, not "commit", but this is
      a backward compatibility baggage we would need to carry around for now.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5231c633
  16. 19 9月, 2011 1 次提交
    • N
      Accept tags in HEAD or MERGE_HEAD · baf18fc2
      Nguyễn Thái Ngọc Duy 提交于
      HEAD and MERGE_HEAD (among other branch tips) should never hold a
      tag. That can only be caused by broken tools and is cumbersome to fix
      by an end user with:
      
        $ git update-ref HEAD $(git rev-parse HEAD^{commit})
      
      which may look like a magic to a new person.
      
      Be easy, warn users (so broken tools can be fixed if they bother to
      report) and move on.
      
      Be robust, if the given SHA-1 cannot be resolved to a commit object,
      die (therefore return value is always valid).
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      baf18fc2
  17. 13 9月, 2011 1 次提交
  18. 07 9月, 2011 1 次提交
  19. 20 8月, 2011 2 次提交
    • J
      want_color: automatically fallback to color.ui · c9bfb953
      Jeff King 提交于
      All of the "do we want color" flags default to -1 to
      indicate that we don't have any color configured. This value
      is handled in one of two ways:
      
        1. In porcelain, we check early on whether the value is
           still -1 after reading the config, and set it to the
           value of color.ui (which defaults to 0).
      
        2. In plumbing, it stays untouched as -1, and want_color
           defaults it to off.
      
      This works fine, but means that every porcelain has to check
      and reassign its color flag. Now that want_color gives us a
      place to put this check in a single spot, we can do that,
      simplifying the calling code.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c9bfb953
    • J
      commit: reduce use of redundant global variables · 06bb643b
      Junio C Hamano 提交于
      The file-scope global variable head_sha1[] was used to hold the object
      name of the current HEAD commit (unless we are about to make an initial
      commit). Also there is an independent "static int initial_commit".
      
      Fix all the functions on the call-chain that use these two variables to
      take a new "(const) struct commit *current_head" argument instead, and
      replace their uses, e.g. "if (initial_commit)" becomes "if (!current_head)"
      and a reference to "head_sha1" becomes "current_head->object.sha1".
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      06bb643b
  20. 19 8月, 2011 1 次提交
  21. 12 8月, 2011 1 次提交
    • C
      ls-files: fix pathspec display on error · 0f64bfa9
      Clemens Buchacher 提交于
      The following sequence of commands reveals an issue with error
      reporting of relative paths:
      
       $ mkdir sub
       $ cd sub
       $ git ls-files --error-unmatch ../bbbbb
       error: pathspec 'b' did not match any file(s) known to git.
       $ git commit --error-unmatch ../bbbbb
       error: pathspec 'b' did not match any file(s) known to git.
      
      This bug is visible only if the normalized path (i.e., the relative
      path from the repository root) is longer than the prefix.
      Otherwise, the code skips over the normalized path and reads from
      an unused memory location which still contains a leftover of the
      original command line argument.
      
      So instead, use the existing facilities to deal with relative paths
      correctly.
      
      Also fix inconsistency between "checkout" and "commit", e.g.
      
          $ cd Documentation
          $ git checkout nosuch.txt
          error: pathspec 'Documentation/nosuch.txt' did not match...
          $ git commit nosuch.txt
          error: pathspec 'nosuch.txt' did not match...
      
      by propagating the prefix down the codepath that reports the error.
      Signed-off-by: NClemens Buchacher <drizzd@aon.at>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0f64bfa9
  22. 03 8月, 2011 1 次提交
    • C
      commit: allow partial commits with relative paths · 8894d535
      Clemens Buchacher 提交于
      In order to do partial commits, git-commit overlays a tree on the
      cache and checks pathspecs against the result. Currently, the
      overlaying is done using "prefix" which prevents relative pathspecs
      with ".." and absolute pathspec from matching when they refer to
      files not under "prefix" and absent from the index, but still in
      the tree (i.e.  files staged for removal).
      
      The point of providing a prefix at all is performance optimization.
      If we say there is no common prefix for the files of interest, then
      we have to read the entire tree into the index.
      
      But even if we cannot use the working directory as a prefix, we can
      still figure out if there is a common prefix for all given paths,
      and use that instead. The pathspec_prefix() routine from ls-files.c
      does exactly that.
      
      Any use of global variables is removed from pathspec_prefix() so
      that it can be called from commit.c.
      Reported-by: NReuben Thomas <rrt@sc3d.org>
      Analyzed-by: NMichael J Gruber <git@drmicha.warpmail.net>
      Signed-off-by: NClemens Buchacher <drizzd@aon.at>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8894d535
  23. 12 5月, 2011 1 次提交
  24. 10 5月, 2011 2 次提交
  25. 09 5月, 2011 1 次提交
  26. 22 3月, 2011 1 次提交
  27. 10 3月, 2011 6 次提交
  28. 09 3月, 2011 3 次提交
    • J
      commit, status: use status_printf{,_ln,_more} helpers · b926c0d1
      Jonathan Nieder 提交于
      wt-status code is used to provide a reminder of changes included and
      not included for the commit message template opened in the operator's
      text editor by "git commit".  Therefore each line of its output begins
      with the comment character "#":
      
      	# Please enter the commit message for your changes. Lines starting
      
      Use the new status_printf{,_ln,_more} functions to take care of adding
      "#" to the beginning of such status lines automatically.  Using these
      will have two advantages over the current code:
      
       - The obvious one is to force separation of the "#" from the
         translatable part of the message when git learns to translate its
         output.
      
       - Another advantage is that this makes it easier for us to drop "#"
         prefix in "git status" output in later versions of git if we want
         to.
      Explained-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b926c0d1
    • J
      commit: refer to commit template as s->fp · 37f3012f
      Jonathan Nieder 提交于
      Instead of maintaining a local variable for it, use s->fp to keep
      track of where the commit message template should be written.
      
      This prepares us to take advantage of the status_printf functions,
      which use a struct wt_status instead of a FILE pointer to determine
      where to send their output.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      37f3012f
    • J
      commit, status: use status_printf{,_ln,_more} helpers · 098d0e0e
      Jonathan Nieder 提交于
      wt-status code is used to provide a reminder of changes included and
      not included for the commit message template opened in the operator's
      text editor by "git commit".  Therefore each line of its output begins
      with the comment character "#":
      
      	# Please enter the commit message for your changes. Lines starting
      
      Use the new status_printf{,_ln,_more} functions to take care of adding
      "#" to the beginning of such status lines automatically.  Using these
      will have two advantages over the current code:
      
       - The obvious one is to force separation of the "#" from the
         translatable part of the message when git learns to translate its
         output.
      
       - Another advantage is that this makes it easier for us to drop "#"
         prefix in "git status" output in later versions of git if we want
         to.
      Explained-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      098d0e0e