git/list[1] front-page[2] threads[3] people[4] search[5] about
 

range-diff should suppress context-only changes?

From
Jeff King <peff@peff.net>
Date
Nov 5, 2020, 13:34 UTC
Message-ID
<20201105133437.GC91972@coredump.intra.peff.net>
On Thu, Nov 05, 2020 at 12:22:32AM +0000, Elijah Newren via GitGitGadget wrote:
Show 25 quoted lines
> Range-diff vs v3:
> [...]
>   7:  42633b8d03 !  7:  5e8004c728 strmap: add more utility functions
>      @@ strmap.h: void *strmap_get(struct strmap *map, const char *str);
>       + * iterate through @map using @iter, @var is a pointer to a type strmap_entry
>       + */
>       +#define strmap_for_each_entry(mystrmap, iter, var)	\
>      -+	for (var = hashmap_iter_first_entry_offset(&(mystrmap)->map, iter, 0); \
>      -+		var; \
>      -+		var = hashmap_iter_next_entry_offset(iter, 0))
>      ++	hashmap_for_each_entry(&(mystrmap)->map, iter, var, ent)
>       +
>        #endif /* STRMAP_H */
>   8:  ea942eb803 =  8:  fd96e9fc8d strmap: enable faster clearing and reusing of strmaps
>   9:  c1d2172171 !  9:  f499934f54 strmap: add functions facilitating use as a string->int map
> [...]
>       @@ strmap.h: static inline int strmap_empty(struct strmap *map)
>      - 		var; \
>      - 		var = hashmap_iter_next_entry_offset(iter, 0))
>      + #define strmap_for_each_entry(mystrmap, iter, var)	\
>      + 	hashmap_for_each_entry(&(mystrmap)->map, iter, var, ent)
>        
>       +
>       +/*
>      @@ strmap.h: static inline int strmap_empty(struct strmap *map)

Definitely not a problem with your patches, but I noticed this curiosity in the range-diff. Patch 7 changes the definition of the macro, but it gets mentioned again in patch 9, even though the code wasn't touched. The issue is that it the change from 7 ends up in the context of 9; the actual modification in patch 9 is in those final couple lines touching a comment (and they didn't change at all between the two versions).

I wonder if it would be reasonable to suppress range-diff hunks in which all of the changed lines are context lines.

-Peff
Next: Junio C Hamano
Message 1 of 7 in “range-diff should suppress context-only changes?”
  1. Jeff KingNov 5, 2020
  2. Junio C HamanoNov 5, 2020
  3. Johannes AltmanningerNov 17, 2020
  4. 1/3 range-diff: move " ## filename ##" headers to the first columnJohannes Altmanninger, Nov 17, 2020
  5. 2/3 range-diff: ignore context-only changesJohannes Altmanninger, Nov 17, 2020
  6. Eric SunshineNov 17, 2020
  7. 3/3 range-diff: only compute patch diff when patches are differentJohannes Altmanninger, Nov 17, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.