1. 25 2月, 2010 1 次提交
  2. 24 2月, 2010 1 次提交
    • N
      move encode_in_pack_object_header() to a better place · f965c525
      Nicolas Pitre 提交于
      Commit 1b22b6c8 made duplicated versions of encode_header() into a
      common version called encode_in_pack_object_header(). There is however
      a better location that sha1_file.c for such a function though, as
      sha1_file.c contains nothing related to the creation of packs, and
      it is quite populated already.
      
      Also the comment that was moved to the header file should really remain
      near the function as it covers implementation details and provides no
      information about the actual function interface.
      Signed-off-by: NNicolas Pitre <nico@fluxnic.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f965c525
  3. 23 2月, 2010 1 次提交
  4. 18 2月, 2010 1 次提交
  5. 17 2月, 2010 1 次提交
  6. 15 2月, 2010 1 次提交
    • J
      Make 'git var GIT_PAGER' always print the configured pager · 64778d24
      Jonathan Nieder 提交于
      Scripted commands that want to use git’s configured pager know better
      than ‘git var’ does whether stdout is going to be a tty at the
      appropriate time.  Checking isatty(1) as git_pager() does now won’t
      cut it, since the output of git var itself is almost never a terminal.
      The symptom is that when used by humans, ‘git var GIT_PAGER’ behaves
      as it should, but when used by scripts, it always returns ‘cat’!
      
      So avoid tricks with isatty() and just always print the configured
      pager.
      
      This does not fix the callers to check isatty(1) themselves yet.
      Nevertheless, this patch alone is enough to fix 'am --interactive'.
      
      Thanks to Sebastian Celis for the report and Jeff King for the
      analysis.
      Reported-by: NSebastian Celis <sebastian@sebastiancelis.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      64778d24
  7. 27 1月, 2010 1 次提交
    • J
      approxidate_careful() reports errorneous date string · 93cfa7c7
      Junio C Hamano 提交于
      For a long time, the time based reflog syntax (e.g. master@{yesterday})
      didn't complain when the "human readable" timestamp was misspelled, as
      the underlying mechanism tried to be as lenient as possible.  The funny
      thing was that parsing of "@{now}" even relied on the fact that anything
      not recognized by the machinery returned the current timestamp.
      
      Introduce approxidate_careful() that takes an optional pointer to an
      integer, that gets assigned 1 when the input does not make sense as a
      timestamp.
      
      As I am too lazy to fix all the callers that use approxidate(), most of
      the callers do not take advantage of the error checking, but convert the
      code to parse reflog to use it as a demonstration.
      
      Tests are mostly from Jeff King.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      93cfa7c7
  8. 19 1月, 2010 1 次提交
  9. 18 1月, 2010 4 次提交
  10. 12 1月, 2010 3 次提交
  11. 11 1月, 2010 1 次提交
    • J
      ident.c: check explicit identity for name and email separately · 91c38a21
      Junio C Hamano 提交于
      bb1ae3f6 (commit: Show committer if automatic, 2008-05-04) added a logic to
      check both name and email were given explicitly by the end user, but it
      assumed that fmt_ident() is never called before git_default_user_config()
      is called, which was fragile.  The former calls setup_ident() and fills
      the "default" name and email, so the check in the config parser would have
      mistakenly said both are given even if only user.name was provided.
      
      Make the logic more robust by keeping track of name and email separately.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      Acked-by: NSanti Béjar <santi@agolina.net>
      91c38a21
  12. 08 1月, 2010 1 次提交
    • J
      unpack-trees.c: prepare for looking ahead in the index · da165f47
      Junio C Hamano 提交于
      This prepares but does not yet implement a look-ahead in the index entries
      when traverse-trees.c decides to give us tree entries in an order that
      does not match what is in the index.
      
      A case where a look-ahead in the index is necessary happens when merging
      branch B into branch A while the index matches the current branch A, using
      a tree O as their common ancestor, and these three trees looks like this:
      
         O        A       B
         t                t
         t-i      t-i     t-i
         t-j      t-j
                  t/1
                  t/2
      
      The traverse_trees() function gets "t", "t-i" and "t" from trees O, A and
      B first, and notices that A may have a matching "t" behind "t-i" and "t-j"
      (indeed it does), and tells A to give that entry instead.  After unpacking
      blob "t" from tree B (as it hasn't changed since O in B and A removed it,
      it will result in its removal), it descends into directory "t/".
      
      The side that walked index in parallel to the tree traversal used to be
      implemented with one pointer, o->pos, that points at the next index entry
      to be processed.  When this happens, the pointer o->pos still points at
      "t-i" that is the first entry.  We should be able to skip "t-i" and "t-j"
      and locate "t/1" from the index while the recursive invocation of
      traverse_trees() walks and match entries found there, and later come back
      to process "t-i".
      
      While that look-ahead is not implemented yet, this adds a flag bit,
      CE_UNPACKED, to mark the entries in the index that has already been
      processed.  o->pos pointer has been renamed to o->cache_bottom and it
      points at the first entry that may still need to be processed.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      da165f47
  13. 04 1月, 2010 2 次提交
    • J
      Fix bit assignment for CE_CONFLICTED · bf96c931
      Junio C Hamano 提交于
      CE_WT_REMOVE has already grabbed the same value.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      bf96c931
    • J
      "reset --merge": fix unmerged case · e11d7b59
      Junio C Hamano 提交于
      Commit 9e8eceab (Add 'merge' mode to 'git reset', 2008-12-01) disallowed
      "git reset --merge" when there was unmerged entries.  But it wished if
      unmerged entries were reset as if --hard (instead of --merge) has been
      used.  This makes sense because all "mergy" operations makes sure that
      any path involved in the merge does not have local modifications before
      starting, so resetting such a path away won't lose any information.
      
      The previous commit changed the behavior of --merge to accept resetting
      unmerged entries if they are reset to a different state than HEAD, but it
      did not reset the changes in the work tree, leaving the conflict markers
      in the resulting file in the work tree.
      
      Fix it by doing three things:
      
       - Update the documentation to match the wish of original "reset --merge"
         better, namely, "An unmerged entry is a sign that the path didn't have
         any local modification and can be safely resetted to whatever the new
         HEAD records";
      
       - Update read_index_unmerged(), which reads the index file into the cache
         while dropping any higher-stage entries down to stage #0, not to copy
         the object name from the higher stage entry.  The code used to take the
         object name from the a stage entry ("base" if you happened to have
         stage #1, or "ours" if both sides added, etc.), which essentially meant
         that you are getting random results depending on what the merge did.
      
         The _only_ reason we want to keep a previously unmerged entry in the
         index at stage #0 is so that we don't forget the fact that we have
         corresponding file in the work tree in order to be able to remove it
         when the tree we are resetting to does not have the path.  In order to
         differentiate such an entry from ordinary cache entry, the cache entry
         added by read_index_unmerged() is marked as CE_CONFLICTED.
      
       - Update merged_entry() and deleted_entry() so that they pay attention to
         cache entries marked as CE_CONFLICTED.  They are previously unmerged
         entries, and the files in the work tree that correspond to them are
         resetted away by oneway_merge() to the version from the tree we are
         resetting to.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e11d7b59
  14. 26 12月, 2009 3 次提交
    • J
      resolve-undo: teach "update-index --unresolve" to use resolve-undo info · 8aa38563
      Junio C Hamano 提交于
      The update-index plumbing command had a hacky --unresolve implementation
      that was written back in the days when merge was the only way for users to
      end up with higher stages in the index, and assumed that stage #2 must
      have come from HEAD, stage #3 from MERGE_HEAD and didn't bother to compute
      the stage #1 information.
      
      There were several issues with this approach:
      
       - These days, merge is not the only command, and conflicts coming from
         commands like cherry-pick, "am -3", etc. cannot be recreated by looking
         at MERGE_HEAD;
      
       - For a conflict that came from a merge that had renames, picking up the
         same path from MERGE_HEAD and HEAD wouldn't help recreating it, either;
      
       - It may have been Ok not to recreate stage #1 back when it was written,
         because "diff --ours/--theirs" were the only availble ways to review
         conflicts and they don't need stage #1 information.  "diff --cc" that
         was invented much later is a lot more useful way but it needs stage #1.
      
      We can use resolve-undo information recorded in the index extension to
      solve all of these issues.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8aa38563
    • J
      resolve-undo: "checkout -m path" uses resolve-undo information · 4421a823
      Junio C Hamano 提交于
      Once you resolved conflicts by "git add path", you cannot recreate the
      conflicted state with "git checkout -m path", because you lost information
      from higher stages in the index when you resolved them.
      
      Since we record the necessary information in the resolve-undo index
      extension these days, we can reproduce the unmerged state in the index and
      check it out.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4421a823
    • J
      resolve-undo: record resolved conflicts in a new index extension section · cfc5789a
      Junio C Hamano 提交于
      When resolving a conflict using "git add" to create a stage #0 entry, or
      "git rm" to remove entries at higher stages, remove_index_entry_at()
      function is eventually called to remove unmerged (i.e. higher stage)
      entries from the index.  Introduce a "resolve_undo_info" structure and
      keep track of the removed cache entries, and save it in a new index
      extension section in the index_state.
      
      Operations like "read-tree -m", "merge", "checkout [-m] <branch>" and
      "reset" are signs that recorded information in the index is no longer
      necessary.  The data is removed from the index extension when operations
      start; they may leave conflicted entries in the index, and later user
      actions like "git add" will record their conflicted states afresh.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cfc5789a
  15. 15 12月, 2009 1 次提交
  16. 08 12月, 2009 1 次提交
  17. 21 11月, 2009 1 次提交
  18. 18 11月, 2009 1 次提交
  19. 16 11月, 2009 1 次提交
  20. 14 11月, 2009 2 次提交
    • J
      Teach git var about GIT_PAGER · 63618245
      Jonathan Nieder 提交于
      Expose the command found by setup_pager() for scripts to use.
      Scripts can use this to avoid repeating the logic to look for a
      proper pager in each command.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      63618245
    • J
      Teach git var about GIT_EDITOR · 44fcb497
      Jonathan Nieder 提交于
      Expose the command used by launch_editor() for scripts to use.
      This should allow one to avoid searching for a proper editor
      separately in each command.
      
      git_editor(void) uses the logic to decide which editor to use
      that used to live in launch_editor().  The function returns NULL
      if there is no suitable editor; the caller is expected to issue
      an error message when appropriate.
      
      launch_editor() uses git_editor() and gives the error message the
      same way as before when EDITOR is not set.
      
      "git var GIT_EDITOR" gives the editor name, or an error message
      when there is no appropriate one.
      
      "git var -l" gives GIT_EDITOR=name only if there is an
      appropriate editor.
      Originally-submitted-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      44fcb497
  21. 10 11月, 2009 1 次提交
    • S
      http-backend: Protect GIT_PROJECT_ROOT from /../ requests · 34b6cb8b
      Shawn O. Pearce 提交于
      Eons ago HPA taught git-daemon how to protect itself from /../
      attacks, which Junio brought back into service in d79374c7
      ("daemon.c and path.enter_repo(): revamp path validation").
      
      I did not carry this into git-http-backend as originally we relied
      only upon PATH_TRANSLATED, and assumed the HTTP server had done
      its access control checks to validate the resolved path was within
      a directory permitting access from the remote client.  This would
      usually be sufficient to protect a server from requests for its
      /etc/passwd file by http://host/smart/../etc/passwd sorts of URLs.
      
      However in 917adc03 Mark Lodato added GIT_PROJECT_ROOT as an
      additional method of configuring the CGI.  When this environment
      variable is used the web server does not generate the final access
      path and therefore may blindly pass through "/../etc/passwd"
      in PATH_INFO under the assumption that "/../" might have special
      meaning to the invoked CGI.
      
      Instead of permitting these sorts of malformed path requests, we
      now reject them back at the client, with an error message for the
      server log.  This matches git-daemon behavior.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      34b6cb8b
  22. 31 10月, 2009 1 次提交
  23. 20 10月, 2009 1 次提交
    • J
      Introduce commit notes · a97a7468
      Johannes Schindelin 提交于
      Commit notes are blobs which are shown together with the commit
      message.  These blobs are taken from the notes ref, which you can
      configure by the config variable core.notesRef, which in turn can
      be overridden by the environment variable GIT_NOTES_REF.
      
      The notes ref is a branch which contains "files" whose names are
      the names of the corresponding commits (i.e. the SHA-1).
      
      The rationale for putting this information into a ref is this: we
      want to be able to fetch and possibly union-merge the notes,
      maybe even look at the date when a note was introduced, and we
      want to store them efficiently together with the other objects.
      
      This patch has been improved by the following contributions:
      - Thomas Rast: fix core.notesRef documentation
      - Tor Arne Vestbø: fix printing of multi-line notes
      - Alex Riesen: Using char array instead of char pointer costs less BSS
      - Johan Herland: Plug leak when msg is good, but msglen or type causes return
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NThomas Rast <trast@student.ethz.ch>
      Signed-off-by: NTor Arne Vestbø <tavestbo@trolltech.com>
      Signed-off-by: NJohan Herland <johan@herland.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      
      get_commit_notes(): Plug memory leak when 'if' triggers, but not because of read_sha1_file() failure
      a97a7468
  24. 19 10月, 2009 1 次提交
    • J
      "checkout A...B" switches to the merge base between A and B · 619a644d
      Junio C Hamano 提交于
      When flipping commits around on topic branches, I often end up doing
      this sequence:
      
       * Run "log --oneline next..jc/frotz" to find out the first commit
         on 'jc/frotz' branch not yet merged to 'next';
      
       * Run "checkout $that_commit^" to detach HEAD to the parent of it;
      
       * Rebuild the series on top of that commit; and
      
       * "show-branch jc/frotz HEAD" and "diff jc/frotz HEAD" to verify.
      
      Introduce a new syntax to "git checkout" to name the commit to switch to,
      to make the first two steps easier.  When the branch to switch to is
      specified as A...B (you can omit either A or B but not both, and HEAD
      is used instead of the omitted side), the merge base between these two
      commits are computed, and if there is one unique one, we detach the HEAD
      at that commit.
      
      With this, I can say "checkout next...jc/frotz".
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      619a644d
  25. 18 10月, 2009 1 次提交
  26. 29 9月, 2009 1 次提交
  27. 13 9月, 2009 2 次提交
    • C
      preserve mtime of local clone · f7835a25
      Clemens Buchacher 提交于
      A local clone without hardlinks copies all objects, including dangling
      ones, to the new repository. Since the mtimes are renewed, those
      dangling objects cannot be pruned by "git gc --prune", even if they
      would have been old enough for pruning in the original repository.
      
      Instead, preserve mtime during copy. "git gc --prune" will then work
      in the clone just like it did in the original.
      Signed-off-by: NClemens Buchacher <drizzd@aon.at>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f7835a25
    • J
      use write_str_in_full helper to avoid literal string lengths · 2b7ca830
      Jim Meyering 提交于
      In 2d14d65c (Use a clearer style to issue commands to remote helpers,
      2009-09-03) I happened to notice two changes like this:
      
      -	write_in_full(helper->in, "list\n", 5);
      +
      +	strbuf_addstr(&buf, "list\n");
      +	write_in_full(helper->in, buf.buf, buf.len);
      +	strbuf_reset(&buf);
      
      IMHO, it would be better to define a new function,
      
          static inline ssize_t write_str_in_full(int fd, const char *str)
          {
                 return write_in_full(fd, str, strlen(str));
          }
      
      and then use it like this:
      
      -       strbuf_addstr(&buf, "list\n");
      -       write_in_full(helper->in, buf.buf, buf.len);
      -       strbuf_reset(&buf);
      +       write_str_in_full(helper->in, "list\n");
      
      Thus not requiring the added allocation, and still avoiding
      the maintenance risk of literal string lengths.
      These days, compilers are good enough that strlen("literal")
      imposes no run-time cost.
      
      Transformed via this:
      
          perl -pi -e \
              's/write_in_full\((.*?), (".*?"), \d+\)/write_str_in_full($1, $2)/'\
            $(git grep -l 'write_in_full.*"')
      Signed-off-by: NJim Meyering <meyering@redhat.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2b7ca830
  28. 12 9月, 2009 1 次提交
    • J
      push: make non-fast-forward help message configurable · 75194438
      Jeff King 提交于
      This message is designed to help new users understand what
      has happened when refs fail to push. However, it does not
      help experienced users at all, and significantly clutters
      the output, frequently dwarfing the regular status table and
      making it harder to see.
      
      This patch introduces a general configuration mechanism for
      optional messages, with this push message as the first
      example.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      75194438
  29. 06 9月, 2009 1 次提交
    • J
      core.whitespace: split trailing-space into blank-at-{eol,eof} · aeb84b05
      Junio C Hamano 提交于
      People who configured trailing-space depended on it to catch both extra
      white space at the end of line, and extra blank lines at the end of file.
      Earlier attempt to introduce only blank-at-eof gave them an escape hatch
      to keep the old behaviour, but it is a regression until they explicitly
      specify the new error class.
      
      This introduces a blank-at-eol that only catches extra white space at the
      end of line, and makes the traditional trailing-space a convenient synonym
      to catch both blank-at-eol and blank-at-eof.  This way, people who used
      trailing-space continue to catch both classes of errors.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      aeb84b05
  30. 05 9月, 2009 1 次提交
    • J
      apply --whitespace=warn/error: diagnose blank at EOF · 77b15bbd
      Junio C Hamano 提交于
      "git apply" strips new blank lines at EOF under --whitespace=fix option,
      but neigher --whitespace=warn nor --whitespace=error paid any attention to
      these errors.
      
      Introduce a new whitespace error class, blank-at-eof, to make the
      whitespace error handling more consistent.
      
      The patch adds a new "linenr" field to the struct fragment in order to
      record which line the hunk started in the input file, but this is needed
      solely for reporting purposes.  The detection of this class of whitespace
      errors cannot be done while parsing a patch like we do for all the other
      classes of whitespace errors.  It instead has to wait until we find where
      to apply the hunk, but at that point, we do not have an access to the
      original line number in the input file anymore, hence the new field.
      
      Depending on your point of view, this may be a bugfix that makes warn and
      error in line with fix.  Or you could call it a new feature.  The line
      between them is somewhat fuzzy in this case.
      
      Strictly speaking, triggering more errors than before is a change in
      behaviour that is not backward compatible, even though the reason for the
      change is because the code was not checking for an error that it should
      have.  People who do not want added blank lines at EOF to trigger an error
      can disable the new error class.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      77b15bbd