1. 01 Nov, 2017 2 commits
    • Brandon Williams's avatar
      diff: make struct diff_flags members lowercase · 0d1e0e78
      Brandon Williams authored
      Now that the flags stored in struct diff_flags are being accessed
      directly and not through macros, change all struct members from being
      uppercase to lowercase.
      This conversion is done using the following semantic patch:
      
      	@@
      	expression E;
      	@@
      	- E.RECURSIVE
      	+ E.recursive
      
      	@@
      	expression E;
      	@@
      	- E.TREE_IN_RECURSIVE
      	+ E.tree_in_recursive
      
      	@@
      	expression E;
      	@@
      	- E.BINARY
      	+ E.binary
      
      	@@
      	expression E;
      	@@
      	- E.TEXT
      	+ E.text
      
      	@@
      	expression E;
      	@@
      	- E.FULL_INDEX
      	+ E.full_index
      
      	@@
      	expression E;
      	@@
      	- E.SILENT_ON_REMOVE
      	+ E.silent_on_remove
      
      	@@
      	expression E;
      	@@
      	- E.FIND_COPIES_HARDER
      	+ E.find_copies_harder
      
      	@@
      	expression E;
      	@@
      	- E.FOLLOW_RENAMES
      	+ E.follow_renames
      
      	@@
      	expression E;
      	@@
      	- E.RENAME_EMPTY
      	+ E.rename_empty
      
      	@@
      	expression E;
      	@@
      	- E.HAS_CHANGES
      	+ E.has_changes
      
      	@@
      	expression E;
      	@@
      	- E.QUICK
      	+ E.quick
      
      	@@
      	expression E;
      	@@
      	- E.NO_INDEX
      	+ E.no_index
      
      	@@
      	expression E;
      	@@
      	- E.ALLOW_EXTERNAL
      	+ E.allow_external
      
      	@@
      	expression E;
      	@@
      	- E.EXIT_WITH_STATUS
      	+ E.exit_with_status
      
      	@@
      	expression E;
      	@@
      	- E.REVERSE_DIFF
      	+ E.reverse_diff
      
      	@@
      	expression E;
      	@@
      	- E.CHECK_FAILED
      	+ E.check_failed
      
      	@@
      	expression E;
      	@@
      	- E.RELATIVE_NAME
      	+ E.relative_name
      
      	@@
      	expression E;
      	@@
      	- E.IGNORE_SUBMODULES
      	+ E.ignore_submodules
      
      	@@
      	expression E;
      	@@
      	- E.DIRSTAT_CUMULATIVE
      	+ E.dirstat_cumulative
      
      	@@
      	expression E;
      	@@
      	- E.DIRSTAT_BY_FILE
      	+ E.dirstat_by_file
      
      	@@
      	expression E;
      	@@
      	- E.ALLOW_TEXTCONV
      	+ E.allow_textconv
      
      	@@
      	expression E;
      	@@
      	- E.TEXTCONV_SET_VIA_CMDLINE
      	+ E.textconv_set_via_cmdline
      
      	@@
      	expression E;
      	@@
      	- E.DIFF_FROM_CONTENTS
      	+ E.diff_from_contents
      
      	@@
      	expression E;
      	@@
      	- E.DIRTY_SUBMODULES
      	+ E.dirty_submodules
      
      	@@
      	expression E;
      	@@
      	- E.IGNORE_UNTRACKED_IN_SUBMODULES
      	+ E.ignore_untracked_in_submodules
      
      	@@
      	expression E;
      	@@
      	- E.IGNORE_DIRTY_SUBMODULES
      	+ E.ignore_dirty_submodules
      
      	@@
      	expression E;
      	@@
      	- E.OVERRIDE_SUBMODULE_CONFIG
      	+ E.override_submodule_config
      
      	@@
      	expression E;
      	@@
      	- E.DIRSTAT_BY_LINE
      	+ E.dirstat_by_line
      
      	@@
      	expression E;
      	@@
      	- E.FUNCCONTEXT
      	+ E.funccontext
      
      	@@
      	expression E;
      	@@
      	- E.PICKAXE_IGNORE_CASE
      	+ E.pickaxe_ignore_case
      
      	@@
      	expression E;
      	@@
      	- E.DEFAULT_FOLLOW_RENAMES
      	+ E.default_follow_renames
      Signed-off-by: default avatarBrandon Williams <bmwill@google.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      0d1e0e78
    • Brandon Williams's avatar
      diff: remove DIFF_OPT_SET macro · 23dcf77f
      Brandon Williams authored
      Remove the `DIFF_OPT_SET` macro and instead set the flags directly.
      This conversion is done using the following semantic patch:
      
      	@@
      	expression E;
      	identifier fld;
      	@@
      	- DIFF_OPT_SET(&E, fld)
      	+ E.flags.fld = 1
      
      	@@
      	type T;
      	T *ptr;
      	identifier fld;
      	@@
      	- DIFF_OPT_SET(ptr, fld)
      	+ ptr->flags.fld = 1
      Signed-off-by: default avatarBrandon Williams <bmwill@google.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      23dcf77f
  2. 05 Jul, 2017 1 commit
  3. 30 Jun, 2017 2 commits
    • Stefan Beller's avatar
      patch-ids.c: use hashmap correctly · 3da492f8
      Stefan Beller authored
      As alluded to in the previous patch, the code in patch-ids.c is
      using the hashmaps API wrong.
      
      Luckily we do not have a bug, as all hashmap functionality that we use
      here (hashmap_get) passes through the keydata.  If hashmap_get_next were
      to be used, a bug would occur as that passes NULL for the key_data.
      
      So instead use the hashmap API correctly and provide the caller required
      data in the compare function via the first argument that always gets
      passed and was setup via the hashmap_init function.
      Signed-off-by: Stefan Beller's avatarStefan Beller <sbeller@google.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      3da492f8
    • Stefan Beller's avatar
      hashmap.h: compare function has access to a data field · 7663cdc8
      Stefan Beller authored
      When using the hashmap a common need is to have access to caller provided
      data in the compare function. A couple of times we abuse the keydata field
      to pass in the data needed. This happens for example in patch-ids.c.
      
      This patch changes the function signature of the compare function
      to have one more void pointer available. The pointer given for each
      invocation of the compare function must be defined in the init function
      of the hashmap and is just passed through.
      
      Documentation of this new feature is deferred to a later patch.
      This is a rather mechanical conversion, just adding the new pass-through
      parameter.  However while at it improve the naming of the fields of all
      compare functions used by hashmaps by ensuring unused parameters are
      prefixed with 'unused_' and naming the parameters what they are (instead
      of 'unused' make it 'unused_keydata').
      Signed-off-by: Stefan Beller's avatarStefan Beller <sbeller@google.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      7663cdc8
  4. 05 Jun, 2017 1 commit
  5. 02 Jun, 2017 3 commits
  6. 08 May, 2017 1 commit
  7. 27 Mar, 2017 1 commit
  8. 12 Sep, 2016 1 commit
    • Jeff King's avatar
      patch-ids: refuse to compute patch-id for merge commit · 7c810407
      Jeff King authored
      The patch-id code which powers "log --cherry-pick" doesn't
      look at whether each commit is a merge or not. It just feeds
      the commit's first parent to the diff, and ignores any
      additional parents.
      
      In theory, this might be useful if you wanted to find
      equivalence between, say, a merge commit and a squash-merge
      that does the same thing.  But it also promotes a false
      equivalence between distinct merges. For example, every
      "merge -s ours" would look identical to an empty commit
      (which is true in a sense, but presumably there was a value
      in merging in the discarded history). Since patch-ids are
      meant for throwing away duplicates, we should err on the
      side of _not_ matching such merges.
      
      Moreover, we may spend a lot of extra time computing these
      merge diffs. In the case that inspired this patch, a "git
      format-patch --cherry-pick" dropped from over 3 minutes to
      less than 3 seconds.
      
      This seems pretty drastic, but is easily explained. The
      command was invoked by a "git rebase" of an older topic
      branch; there had been tens of thousands of commits on the
      upstream branch in the meantime. In addition, this project
      used a topic-branch workflow with occasional "back-merges"
      from "master" to each topic (to resolve conflicts on the
      topics rather than in the merge commits). So there were not
      only extra merges, but the diffs for these back-merges were
      generally quite large (because they represented _everything_
      that had been merged to master since the topic branched).
      
      This patch treats a merge fed to commit_patch_id() or
      add_commit_patch_id() as an error, and a lookup for such a
      merge via has_commit_patch_id() will always return NULL.
      An earlier version of the patch tried to distinguish between
      "error" and "patch id for merges not defined", but that
      becomes unnecessarily complicated. The only callers are:
      
        1. revision traversals which want to do --cherry-pick;
           they call add_commit_patch_id(), but do not care if it
           fails. They only want to add what we can, look it up
           later with has_commit_patch_id(), and err on the side
           of not-matching.
      
        2. format-patch --base, which calls commit_patch_id().
           This _does_ notice errors, but should never feed a
           merge in the first place (and if it were to do so
           accidentally, then this patch is a strict improvement;
           we notice the bug rather than generating a bogus
           patch-id).
      
      So in both cases, this does the right thing.
      Helped-by: Johannes Schindelin's avatarJohannes Schindelin <Johannes.Schindelin@gmx.de>
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      7c810407
  9. 09 Sep, 2016 1 commit
    • Jeff King's avatar
      patch-ids: turn off rename detection · 5a29cbc6
      Jeff King authored
      The patch-id code may be running inside another porcelain
      like "git log" or "git format-patch", and therefore may have
      set diff_detect_rename_default, either via the diff-ui
      config, or by default since 5404c116 (diff: activate
      diff.renames by default, 2016-02-25). This is the case even
      if a command is run with `--no-renames`, as that is applied
      only to the diff-options used by the command itself.
      
      Rename detection doesn't help the patch-id results. It
      _may_ actually hurt, as minor differences in the files that
      would be overlooked by patch-id's canonicalization might
      result in different renames (though I'd doubt that it ever
      comes up in practice).
      
      But mostly it is just a waste of CPU to compute these
      renames.
      
      Note that this does have one user-visible impact: the
      prerequisite patches listed by "format-patch --base". There
      may be some confusion between different versions of git as
      older ones will enable renames, but newer ones will not.
      However, this was already a problem, as people with
      different settings for the "diff.renames" config would get
      different results. After this patch, everyone should get the
      same results, regardless of their config.
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      5a29cbc6
  10. 11 Aug, 2016 1 commit
    • Kevin Willford's avatar
      rebase: avoid computing unnecessary patch IDs · b3dfeebb
      Kevin Willford authored
      The `rebase` family of Git commands avoid applying patches that were
      already integrated upstream. They do that by using the revision walking
      option that computes the patch IDs of the two sides of the rebase
      (local-only patches vs upstream-only ones) and skipping those local
      patches whose patch ID matches one of the upstream ones.
      
      In many cases, this causes unnecessary churn, as already the set of
      paths touched by a given commit would suffice to determine that an
      upstream patch has no local equivalent.
      
      This hurts performance in particular when there are a lot of upstream
      patches, and/or large ones.
      
      Therefore, let's introduce the concept of a "diff-header-only" patch ID,
      compare those first, and only evaluate the "full" patch ID lazily.
      
      Please note that in contrast to the "full" patch IDs, those
      "diff-header-only" patch IDs are prone to collide with one another, as
      adjacent commits frequently touch the very same files. Hence we now
      have to be careful to allow multiple hash entries with the same hash.
      We accomplish that by using the hashmap_add() function that does not even
      test for hash collisions.  This also allows us to evaluate the full patch ID
      lazily, i.e. only when we found commits with matching diff-header-only
      patch IDs.
      
      We add a performance test that demonstrates ~1-6% improvement.  In
      practice this will depend on various factors such as how many upstream
      changes and how big those changes are along with whether file system
      caches are cold or warm.  As Git's test suite has no way of catching
      performance regressions, we also add a regression test that verifies
      that the full patch ID computation is skipped when the diff-header-only
      computation suffices.
      Signed-off-by: default avatarKevin Willford <kcwillford@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      b3dfeebb
  11. 29 Jul, 2016 3 commits
  12. 26 Apr, 2016 1 commit
  13. 20 Nov, 2015 2 commits
  14. 03 Mar, 2014 1 commit
  15. 03 Aug, 2012 1 commit
    • Thomas Rast's avatar
      diff_setup_done(): return void · 28452655
      Thomas Rast authored
      diff_setup_done() has historically returned an error code, but lost
      the last nonzero return in 943d5b73 (allow diff.renamelimit to be set
      regardless of -M/-C, 2006-08-09).  The callers were in a pretty
      confused state: some actually checked for the return code, and some
      did not.
      
      Let it return void, and patch all callers to take this into account.
      This conveniently also gets rid of a handful of different(!) error
      messages that could never be triggered anyway.
      
      Note that the function can still die().
      Signed-off-by: default avatarThomas Rast <trast@student.ethz.ch>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      28452655
  16. 05 Apr, 2009 1 commit
  17. 12 Nov, 2007 1 commit
  18. 12 Apr, 2007 1 commit
    • Junio C Hamano's avatar
      Refactor patch-id filtering out of git-cherry and git-format-patch. · 5d23e133
      Junio C Hamano authored
      This implements the patch-id computation and recording library,
      patch-ids.c, and rewrites the get_patch_ids() function used in
      cherry and format-patch to use it, so that they do not pollute
      the object namespace.  Earlier code threw non-objects into the
      in-core object database, and hoped for not getting bitten by
      SHA-1 collisions.  While it may be practically Ok, it still was
      an ugly hack.
      Signed-off-by: default avatarJunio C Hamano <junkio@cox.net>
      5d23e133