View Issue Details

IDProjectCategoryView StatusLast Update
0000191fileGeneralpublic2020-09-09 23:22
Reportervinc17 Assigned Tochristos  
PrioritynormalSeverityfeatureReproducibilityN/A
Status assignedResolutionopen 
Summary0000191: differentiate git commits and git commit logs
DescriptionA file starting with "commit " followed by a hash can be one of the various kinds of Git files. In particular, it can be:
1. a single commit with diff output, e.g. what "git show" outputs;
2. a git commit log, e.g. what "git log" outputs (there may also be various kinds of stats, such as with --stat);
3. a git commit log with diff output, e.g. what "git log --patch" outputs.

(1) and (2) are common. (3), which consists of a sequence of commits like in (2), but each one (except merge commits) with a diff like in (1), is possible, but I think that I've never seen it in practice.

For all of them, "file" outputs a description of the form "Git commit <hash>". This is particularly misleading for commit log files (2) as such files almost always contain several commits (thus several hashes). It should at least differentiate (1) and (2). Differentiating (3) from (1) is possible by reading a sufficient number of bytes, and I think that this is OK as this can be controlled by the end user with option -P (--parameter).

In the case the first line has the form "commit <hash>", I suggest to change the tests to output (depending on what one wishes for a single commit with no diff output):

1. If there are no lines starting with "diff ", output "Git commit log".
2. If there is another line of the form "commit <hash>", output "Git commit log with diff output".
3. Otherwise output "Git commit <hash>".

or

1. If there isn't another line of the form "commit <hash>", output "Git commit <hash>".
2. If there are no lines starting with "diff ", output "Git commit log".
3. Otherwise output "Git commit log with diff output".

where <hash> in the output is the hash obtained in the first line (which is what "file" currently gives).

Note: I think that if there is a diff, a "diff " line will occur in the first non-merge commit, so that there is room for optimization.
Steps To ReproduceOn a git repository, check the output with:
$ git show
$ git log
$ git log --patch
TagsNo tags attached.

Activities

christos

2020-09-06 14:54

manager   ~0003481

I don't see any such files, can you post some examples?

vinc17

2020-09-09 23:22

reporter   ~0003484

I have added the 3 cases:
1. single-commit.txt (a single commit with diff output: what "git show" outputs)
2. commit-log.txt (a git commit log: what "git log" outputs)
3. commit-log-with-diff.txt (a git commit log with diff output: what "git log --patch" outputs)
commit-log.txt (289 bytes)   
commit a29df8dd7d0def28b30f0281344d58093118ca18
Author: Vincent Lefevre <vincent@vinc17.net>
Date:   2020-09-10 01:15:03 +0200

    added file2

commit 822309b3b8fcac187ec491b25c04bf86a637d755
Author: Vincent Lefevre <vincent@vinc17.net>
Date:   2020-09-10 01:13:34 +0200

    added file1
commit-log.txt (289 bytes)   
commit-log-with-diff.txt (523 bytes)   
commit a29df8dd7d0def28b30f0281344d58093118ca18
Author: Vincent Lefevre <vincent@vinc17.net>
Date:   2020-09-10 01:15:03 +0200

    added file2

diff --git a/file2 b/file2
new file mode 100644
index 0000000..5716ca5
--- /dev/null
+++ b/file2
@@ -0,0 +1 @@
+bar

commit 822309b3b8fcac187ec491b25c04bf86a637d755
Author: Vincent Lefevre <vincent@vinc17.net>
Date:   2020-09-10 01:13:34 +0200

    added file1

diff --git a/file1 b/file1
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/file1
@@ -0,0 +1 @@
+foo
commit-log-with-diff.txt (523 bytes)   
single-commit.txt (261 bytes)   
commit a29df8dd7d0def28b30f0281344d58093118ca18
Author: Vincent Lefevre <vincent@vinc17.net>
Date:   2020-09-10 01:15:03 +0200

    added file2

diff --git a/file2 b/file2
new file mode 100644
index 0000000..5716ca5
--- /dev/null
+++ b/file2
@@ -0,0 +1 @@
+bar
single-commit.txt (261 bytes)   

Issue History

Date Modified Username Field Change
2020-08-26 13:37 vinc17 New Issue
2020-09-06 14:53 christos Assigned To => christos
2020-09-06 14:53 christos Status new => assigned
2020-09-06 14:54 christos Status assigned => feedback
2020-09-06 14:54 christos Note Added: 0003481
2020-09-09 23:22 vinc17 File Added: commit-log.txt
2020-09-09 23:22 vinc17 File Added: commit-log-with-diff.txt
2020-09-09 23:22 vinc17 File Added: single-commit.txt
2020-09-09 23:22 vinc17 Note Added: 0003484
2020-09-09 23:22 vinc17 Status feedback => assigned