1. 06 Mar, 2014 1 commit
  2. 07 May, 2012 1 commit
  3. 04 May, 2012 2 commits
    • Jeff King's avatar
      reflog-walk: always make [email protected]{0} show indexed selectors · 794151e9
      Jeff King authored
      When we are showing reflog selectors during a walk, we infer
      from context whether the user wanted to see the index in
      each selector, or the reflog date. The current rules are:
      
        1. if the user asked for an explicit date format in the
           output, show the date
      
        2. if the user asked for [email protected]{now}, show the date
      
        3. if neither is true, show the index
      
      However,  if we see "[email protected]{0}", that should be a strong clue
      that the user wants to see the counted version. In fact, it
      should be much stronger than the date format in (1). The
      user may have been setting the date format to use in another
      part of the output (e.g., in --format="%gd (%ad)", they may
      have wanted to influence the author date).
      
      This patch flips the rules to:
      
        1. if the user asked for [email protected]{0}, always show the index
      
        2. if the user asked for [email protected]{now}, always show the date
      
        3. otherwise, we have just "ref"; show them counted by
           default, but respect the presence of "--date" as a clue
           that the user wanted them date-based
      Signed-off-by: default avatarJeff King <[email protected]>
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      794151e9
    • Jeff King's avatar
      reflog-walk: clean up "flag" field of commit_reflog struct · a763126b
      Jeff King authored
      When we prepare to walk a reflog, we parse the specification
      and pull some information from it, such as which reflog to
      look in (e.g., HEAD), and where to start (e.g., [email protected]{10} or
      [email protected]{yesterday}). The resulting struct has a "recno" field
      to show where in the reflog we are starting. It also has a
      "flag" field; if true, it means the recno field came from
      parsing a date like [email protected]{yesterday}.
      
      There are two problems with this:
      
        1. "flag" is an absolutely terrible name, as it conveys
           nothing about the meaning
      
        2. you can tell "HEAD" from "[email protected]{yesterday}", but you
           can't differentiate "HEAD" from "HEAD{0}"
      
      This patch converts the flag into a tri-state (and gives it
      a better name!).
      Signed-off-by: default avatarJeff King <[email protected]>
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      a763126b
  4. 16 Dec, 2011 1 commit
  5. 13 Dec, 2011 1 commit
  6. 06 Dec, 2011 1 commit
    • Duy Nguyen's avatar
      Copy resolve_ref() return value for longer use · d5a35c11
      Duy Nguyen authored
      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 <[email protected]> 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: Duy Nguyen's avatarNguyễn Thái Ngọc Duy <[email protected]>
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      d5a35c11
  7. 24 Nov, 2010 1 commit
    • Jeff King's avatar
      reflogs: clear flags properly in corner case · ffa1eeae
      Jeff King authored
      The reflog-walking mechanism is based on the regular
      revision traversal. We just rewrite the parents of each
      commit in fake_reflog_parent to point to the commit in the
      next reflog entry instead of the real parents.
      
      However, the regular revision traversal tries not to show
      the same commit twice, and so sets the SHOWN flag on each
      commit it shows. In a reflog, however, we may want to see
      the same commit more than once if it appears in the reflog
      multiple times (which easily happens, for example, if you do
      a reset to a prior state).
      
      The fake_reflog_parent function takes care of this by
      clearing flags, including SHOWN. Unfortunately, it does so
      at the very end of the function, and it is possible to
      return early from the function if there is no fake parent to
      set up (e.g., because we are at the very first reflog entry
      on the branch). In such a case the flag is not cleared, and
      the entry is skipped by the revision traversal machinery as
      already shown.
      
      You can see this by walking the log of a ref which is set to
      its very first commit more than once (the test below shows
      such a situation). In this case the reflog walk will fail to
      show the entry for the initial creation of the ref.
      
      We don't want to simply move the flag-clearing to the top of
      the function; we want to make sure flags set during the
      fake-parent installation are also cleared. Instead, let's
      hoist the flag-clearing out of the fake_reflog_parent
      function entirely. It's not really about fake parents
      anyway, and the only caller is the get_revision machinery.
      Reported-by: default avatarMartin von Zweigbergk <[email protected]>
      Signed-off-by: default avatarJeff King <[email protected]>
      Acked-by: Johannes Schindelin's avatarJohannes Schindelin <[email protected]>
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      ffa1eeae
  8. 27 Jun, 2010 2 commits
  9. 20 Oct, 2009 2 commits
    • Thomas Rast's avatar
      Introduce new pretty formats %g[sdD] for reflog information · 8f8f5476
      Thomas Rast authored
      Add three new --pretty=format escapes:
      
        %gD  long  reflog descriptor (e.g. refs/[email protected]{0})
        %gd  short reflog descriptor (e.g. [email protected]{0})
        %gs  reflog message
      
      This is achieved by passing down the reflog info, if any, inside the
      pretty_print_context struct.
      
      We use the newly refactored get_reflog_selector(), and give it some
      extra functionality to extract a shortened ref.  The shortening is
      cached inside the commit_reflogs struct; the only allocation of it
      happens in read_complete_reflog(), where it is initialised to 0.  Also
      add another helper get_reflog_message() for the message extraction.
      
      Note that the --format="%h %gD: %gs" tests may not work in real
      repositories, as the --pretty formatter doesn't know to leave away the
      ": " on the last commit in an incomplete (because git-gc removed the
      old part) reflog.  This equivalence is nevertheless the main goal of
      this patch.
      
      Thanks to Jeff King for reviews, the %gd testcase and documentation.
      Signed-off-by: default avatarThomas Rast <[email protected]>
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      8f8f5476
    • Thomas Rast's avatar
      reflog-walk: refactor the [email protected]{num} formatting · 72b103fe
      Thomas Rast authored
      We'll use the same output in an upcoming commit, so refactor its
      formatting (which was duplicated anyway) into a separate function.
      Signed-off-by: default avatarThomas Rast <[email protected]>
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      72b103fe
  10. 01 May, 2009 1 commit
  11. 20 Mar, 2009 1 commit
    • Jeff King's avatar
      make oneline reflog dates more consistent with multiline format · cd437120
      Jeff King authored
      The multiline reflog format (e.g., as shown by "git log -g")
      will show [email protected]{<date>} rather than [email protected]{<count>} in two
      situations:
      
        1. If the user gave [email protected]{<date>} syntax to specify the
           reflog
      
        2. If the user gave a --date=<format> specifier
      
      It uses the "normal" date format in case 1, and the
      user-specified format in case 2.
      
      The oneline reflog format (e.g., "git reflog show" or "git
      log -g --oneline") will show the date in the same two
      circumstances. However, it _always_ shows the date as a
      relative date, and it always ignores the timezone.
      
      In case 2, it seems ridiculous to trigger the date but use a
      format totally different from what the user requested.
      
      For case 1, it is arguable that the user might want to see
      the relative date by default; however, the multiline version
      shows the normal format.
      
      This patch does three things:
      
        - refactors the "relative_date" parameter to
          show_reflog_message to be an actual date_mode enum,
          since this is how it is used (it is passed to show_date)
      
        - uses the passed date_mode parameter in the oneline
          format (making it consistent with the multiline format)
      
        - does not ignore the timezone parameter in oneline mode
      Signed-off-by: default avatarJeff King <[email protected]>
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      cd437120
  12. 22 Jul, 2008 1 commit
    • Johannes Schindelin's avatar
      Rename path_list to string_list · c455c87c
      Johannes Schindelin authored
      The name path_list was correct for the first usage of that data structure,
      but it really is a general-purpose string list.
      
      $ perl -i -pe 's/path-list/string-list/g' $(git grep -l path-list)
      $ perl -i -pe 's/path_list/string_list/g' $(git grep -l path_list)
      $ git mv path-list.h string-list.h
      $ git mv path-list.c string-list.c
      $ perl -i -pe 's/has_path/has_string/g' $(git grep -l has_path)
      $ perl -i -pe 's/path/string/g' string-list.[ch]
      $ git mv Documentation/technical/api-path-list.txt \
      	Documentation/technical/api-string-list.txt
      $ perl -i -pe 's/strdup_paths/strdup_strings/g' $(git grep -l strdup_paths)
      
      ... and then fix all users of string-list to access the member "string"
      instead of "path".
      
      Documentation/technical/api-string-list.txt needed some rewrapping, too.
      Signed-off-by: Johannes Schindelin's avatarJohannes Schindelin <[email protected]>
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      c455c87c
  13. 25 Jul, 2007 1 commit
  14. 09 Feb, 2007 2 commits
  15. 02 Feb, 2007 1 commit
  16. 28 Jan, 2007 1 commit
  17. 21 Jan, 2007 5 commits