Skip to content

Conversation

@darkdread
Copy link

@darkdread darkdread commented Nov 21, 2025

This change allows user to set an option to prepend line numbers to line output in diffs. I use it for prompting.
An example output:

diff --git a/builtin-http-fetch.c b/http-fetch.c
similarity index 95%
rename from builtin-http-fetch.c
rename to http-fetch.c
index f3e63d7..e8f44ba 100644
--- a/builtin-http-fetch.c
+++ b/http-fetch.c
@@ -1,8 +1,9 @@
1  #include "cache.h"
2  #include "walker.h"
3
4 -int cmd_http_fetch(int argc, const char **argv, const char *prefix)
4 +int main(int argc, const char **argv)
5  {
6 +       const char *prefix;
7         struct walker *walker;
8         int commits_on_stdin = 0;
@@ -18,6 +19,8 @@ int cmd_http_fetch(int argc, const char **argv, const char *prefix)
19         int get_verbosely = 0;
20         int get_recover = 0;
21
22 +       prefix = setup_git_directory();
23 +
24         git_config(git_default_config, NULL);
25
26         while (arg < argc && argv[arg][0] == '-') {

No unit test is added as I'm not sure how the internal program works.. feel free to decline if it's irrelevant to the project.

@jnareb
Copy link

jnareb commented Nov 25, 2025

If you provide line numbers, you should provide two columns: for pre-image and for post-image, isn't it?

Or do you decide to provide lines only for post-image - what then to do with deleted / changed lines? Currently it seems like you want pre-image line number... but this might mean non-monotonic line numbers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants