1. 14 6月, 2014 1 次提交
  2. 25 2月, 2014 2 次提交
    • N
      pathspec: pass directory indicator to match_pathspec_item() · ae8d0824
      Nguyễn Thái Ngọc Duy 提交于
      This patch activates the DO_MATCH_DIRECTORY code in m_p_i(), which
      makes "git diff HEAD submodule/" and "git diff HEAD submodule" produce
      the same output. Previously only the version without trailing slash
      returns the difference (if any).
      
      That's the effect of new ce_path_match(). dir_path_match() is not
      executed by the new tests. And it should not introduce regressions.
      
      Previously if path "dir/" is passed in with pathspec "dir/", they
      obviously match. With new dir_path_match(), the path becomes
      _directory_ "dir" vs pathspec "dir/", which is not executed by the old
      code path in m_p_i(). The new code path is executed and produces the
      same result.
      
      The other case is pathspec "dir" and path "dir/" is now turned to
      "dir" (with DO_MATCH_DIRECTORY). Still the same result before or after
      the patch.
      
      So why change? Because of the next patch about clean.c.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ae8d0824
    • N
      pathspec: rename match_pathspec_depth() to match_pathspec() · 854b0959
      Nguyễn Thái Ngọc Duy 提交于
      A long time ago, for some reason I was not happy with
      match_pathspec(). I created a better version, match_pathspec_depth()
      that was suppose to replace match_pathspec()
      eventually. match_pathspec() has finally been gone since 6 months
      ago. Use the shorter name for match_pathspec_depth().
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      854b0959
  3. 16 7月, 2013 2 次提交
  4. 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
  5. 05 4月, 2013 1 次提交
    • J
      rerere forget: do not segfault if not all stages are present · b9e31f59
      Johannes Sixt 提交于
      The loop that fills in the buffers that are later passed to the merge
      driver exits early when not all stages of a path are present in the index.
      But since the buffer pointers are not initialized in advance, the
      subsequent accesses are undefined.
      
      Initialize buffer pointers in advance to avoid undefined behavior later.
      
      That is not sufficient, though, to get correct operation of handle_cache().
      The function replays a conflicted merge to extract the part inside the
      conflict markers. As written, the loop exits early when a stage is missing.
      Consequently, the buffers for later stages that would be present in the
      index are not filled in and the merge is replayed with incomplete data.
      
      Fix it by investigating all stages of the given path.
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b9e31f59
  6. 03 4月, 2013 1 次提交
  7. 16 9月, 2012 1 次提交
  8. 10 7月, 2012 1 次提交
  9. 08 6月, 2012 1 次提交
  10. 27 5月, 2011 2 次提交
  11. 09 5月, 2011 1 次提交
  12. 04 4月, 2011 1 次提交
  13. 24 3月, 2011 1 次提交
    • J
      rerere: make sure it works even in a workdir attached to a young repository · 90a6464b
      Junio C Hamano 提交于
      The git-new-workdir script in contrib/ makes a new work tree by sharing
      many subdirectories of the .git directory with the original repository.
      When rerere.enabled is set in the original repository, but the user has
      not encountered any conflicts yet, the original repository may not yet
      have .git/rr-cache directory.
      
      When rerere wants to run in a new work tree created from such a young
      original repository, it fails to mkdir(2) .git/rr-cache that is a symlink
      to a yet-to-be-created directory.
      
      There are three possible approaches to this:
      
       - A naive solution is not to create a symlink in the git-new-workdir
         script to a directory the original does not have (yet).  This is not a
         solution, as we tend to lazily create subdirectories of .git/, and
         having rerere.enabled configuration set is a strong indication that the
         user _wants_ to have this lazy creation to happen;
      
       - We could always create .git/rr-cache upon repository creation.  This is
         tempting but will not help people with existing repositories.
      
       - Detect this case by seeing that mkdir(2) failed with EEXIST, checking
         that the path is a symlink, and try running mkdir(2) on the link
         target.
      
      This patch solves the issue by doing the third one.
      
      Strictly speaking, this is incomplete.  It does not attempt to handle
      relative symbolic link that points into the original repository, but this
      is good enough to help people who use contrib/workdir/git-new-workdir
      script.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      90a6464b
  14. 17 2月, 2011 1 次提交
    • M
      rerere "remaining" · ac49f5ca
      Martin von Zweigbergk 提交于
      After "rerere" resolves conflicts by reusing old resolution, there would
      be three kinds of paths with conflict in the index:
      
       * paths that have been resolved in the working tree by rerere;
       * paths that need further work whose resolution could be recorded;
       * paths that need resolving that rerere won't help.
      
      When the user wants a list of paths that need hand-resolving, output from
      "rerere status" does not help, as it shows only the second category, but
      the paths in the third category still needs work (rerere only makes sense
      for regular files that have both our side and their side, and does not
      help other kinds of conflicts, e.g. "we modified, they deleted").
      
      The new subcommand "rerere remaining" can be used to show both. As
      opposed to "rerere status", this subcommand also skips printing paths
      that have been added to the index, since these paths are already
      resolved and are no longer "remaining".
      
      Initial patch provided by Junio. Refactored and modified to skip
      resolved paths by Martin. Commit message mostly by Junio.
      Helped-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NMartin von Zweigbergk <martin.von.zweigbergk@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ac49f5ca
  15. 27 8月, 2010 1 次提交
  16. 07 8月, 2010 2 次提交
    • J
      rerere: never renormalize · ff8ba59e
      Jonathan Nieder 提交于
      plain rerere performs three tasks; let us consider how the new
      merge.renormalize option should apply to each.
      
      After an unsuccessful merge, rerere records conflict hunks from the
      work tree under .git/rr-cache.  If the merge was performed with
      merge.renormalize enabled, both sides of the conflict hunk use the
      current work tree’s end-of-line and smudge rules; there is not really
      much of a choice.
      
      After a successful manual resolution, rerere records the postimage.
      Here, also, the file will be in the current work tree’s canonical
      format and there is not much to do about it.
      
      When encountering that conflict again, merge looks up the preimage
      and postimage using the conflict hunk as a key and runs a three-way
      merge to apply that resolution to the work tree.  Since the conflict
      hunk used the current work tree’s canonical format, chances are the
      version in the work tree, the preimage, and the postimage will, too.
      In fact using the merge.renormalize machinery is exactly the wrong
      thing to do, since its result has been run through convert_to_git
      and therefore is not suitable for writing to the work tree.
      
      The only affected caller is "git merge".
      
      NEEDSWORK: lacks test
      
      Cc: Eyvind Bernhardsen <eyvind.bernhardsen@gmail.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ff8ba59e
    • J
      ll-merge: let caller decide whether to renormalize · 18b037a5
      Jonathan Nieder 提交于
      Add a “renormalize” bit to the ll-merge options word so callers can
      decide on a case-by-case basis whether the merge is likely to have
      overlapped with a change in smudge/clean rules.
      
      This reveals a few commands that have not been taking that situation
      into account, though it does not fix them.
      
      No functional change intended.
      
      Cc: Eyvind Bernhardsen <eyvind.bernhardsen@gmail.com>
      Improved-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      18b037a5
  17. 15 7月, 2010 1 次提交
    • S
      rerere: fix overeager gc · 7d7ff15b
      SZEDER Gábor 提交于
      'rerere gc' prunes resolutions of conflicted merges that occurred long
      time ago, and when doing so it takes the creation time of the
      conflicted automerge results into account.  This can cause the loss of
      frequently used conflict resolutions (e.g. long-living topic branches
      are merged into a regularly rebuilt integration branch (think of git's
      pu)) when they become old enough to exceed 'rerere gc's threshold.
      
      To prevent the loss of valuable merge resolutions 'rerere' will (1)
      update the timestamp of the recorded conflict resolution (i.e.
      'postimage') each time when encountering and resolving the same merge
      conflict, and (2) take this timestamp, i.e. the time of the last usage
      into account when gc'ing.
      Signed-off-by: NSZEDER Gábor <szeder@ira.uka.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7d7ff15b
  18. 06 7月, 2010 1 次提交
  19. 28 6月, 2010 1 次提交
  20. 01 6月, 2010 1 次提交
    • G
      enums: omit trailing comma for portability · 4b05548f
      Gary V. Vaughan 提交于
      Without this patch at least IBM VisualAge C 5.0 (I have 5.0.2) on AIX
      5.1 fails to compile git.
      
      enum style is inconsistent already, with some enums declared on one
      line, some over 3 lines with the enum values all on the middle line,
      sometimes with 1 enum value per line... and independently of that the
      trailing comma is sometimes present and other times absent, often
      mixing with/without trailing comma styles in a single file, and
      sometimes in consecutive enum declarations.
      
      Clearly, omitting the comma is the more portable style, and this patch
      changes all enum declarations to use the portable omitted dangling
      comma style consistently.
      Signed-off-by: NGary V. Vaughan <gary@thewrittenword.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4b05548f
  21. 21 3月, 2010 1 次提交
  22. 24 2月, 2010 1 次提交
  23. 29 1月, 2010 1 次提交
  24. 17 1月, 2010 4 次提交
  25. 11 1月, 2010 2 次提交
    • J
      rerere forget path: forget recorded resolution · dea4562b
      Junio C Hamano 提交于
      After you find out an earlier resolution you told rerere to use was a
      mismerge, there is no easy way to clear it.  A new subcommand "forget" can
      be used to tell git to forget a recorded resolution, so that you can redo
      the merge from scratch.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      dea4562b
    • J
      rerere: refactor rerere logic to make it independent from I/O · 27d6b085
      Junio C Hamano 提交于
      This splits the handle_file() function into in-core part and I/O
      parts of the logic to create the preimage, so that we can compute
      the conflict identifier without having to use temporary files.
      
      Earlier, I thought the output from handle_file() should also be
      refactored, but it is always about writing preimage (or thisimage)
      that is used for later three-way merge, so it is saner to keep it
      to always write to FILE *.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      27d6b085
  26. 26 12月, 2009 1 次提交
  27. 04 12月, 2009 1 次提交
  28. 13 9月, 2009 1 次提交
    • 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
  29. 30 4月, 2009 1 次提交
    • A
      replace direct calls to unlink(2) with unlink_or_warn · 691f1a28
      Alex Riesen 提交于
      This helps to notice when something's going wrong, especially on
      systems which lock open files.
      
      I used the following criteria when selecting the code for replacement:
      - it was already printing a warning for the unlink failures
      - it is in a function which already printing something or is
        called from such a function
      - it is in a static function, returning void and the function is only
        called from a builtin main function (cmd_)
      - it is in a function which handles emergency exit (signal handlers)
      - it is in a function which is obvously cleaning up the lockfiles
      Signed-off-by: NAlex Riesen <raa.lkml@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      691f1a28
  30. 15 2月, 2009 1 次提交
    • S
      rerere: remove duplicated functions · 90056966
      SZEDER Gábor 提交于
      Both rerere.c and builtin-rerere.c define the static functions
      rr_path() and has_resolution() the exact same way.  To eliminate this
      code duplication this patch turns the functions in rerere.c
      non-static, and makes builtin-rerere.c use them.  Also, since this
      puts these two functions into the global namespace, rename them to
      rerere_path() and has_rerere_resolution(), respectively, and rename
      their "name" parameter to "hex", because it better reflects what that
      parameter actually is.
      Signed-off-by: NSZEDER Gábor <szeder@ira.uka.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      90056966
  31. 11 2月, 2009 1 次提交
  32. 05 12月, 2008 1 次提交