From: "René Scharfe" <l.s.r@web.de>
To: "Мария Долгополова" <dolgopolovamariia@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Git log: filtering by date and by lines do not work together
Date: Sat, 4 Jul 2020 14:56:23 +0200 [thread overview]
Message-ID: <2c4a6657-1a47-cfbb-21cd-04f131d2ed49@web.de> (raw)
In-Reply-To: <CAD6JL5SRvB_yXcqJ5HGADQaGtZAiKrtd447vtHLSagJqNGPChA@mail.gmail.com>
Am 03.07.20 um 16:14 schrieb Мария Долгополова:
> Hi! I would like to report the bug.
>
> I want to get commits that change specific lines in a specific file
> and were made before a specific date.
>
> Steps:
> 1) I apply filtering by date: --before="2016-11-18"
> Result is in the picture FilteringByDate.png. Commit
> 570778797effd69bd4536c51125b7d2e8f654c08 is presented.
>
> 2) I apply filtering by lines:
> -L33,34:src/main/java/org/toradocu/translator/Subject.java
> Result is in the picture FilteringByLines.png . Commit
> 570778797effd69bd4536c51125b7d2e8f654c08 is presented.
>
> 3) Finally, I apply filtering by lines and by date:
> --before="2016-11-18"
> -L33,34:src/main/java/org/toradocu/translator/Subject.java
> Result is in the picture FilteringByDatesAndLines.png . Commit
> 570778797effd69bd4536c51125b7d2e8f654c08 is NOT presented.
>
> Expected Result: the commit is presented in filter 1 and in filter 2,
> so it must be presented in filter “1 AND 2”
>
> Actual Result: the commit is NOT presented in filter “1 AND 2”
>
> Environment: git version 2.27.0.windows.1
>
> I beg you to provide me with a workaround. I am doing research work
> on analyzing commits in open source projects. Therefore, this
> functionality is very important to me.
You could do the date filtering on the output of git log, e.g.:
git log -L33,34:src/main/java/org/toradocu/translator/Subject.java --date=short --color=always |
awk -v before=2016-11-18 '
/^[^ ]*commit/ {state=1; header=""}
/^[^ ]*Date:/ {if ($2 <= before) {state=2; printf "%s", header} else {state=0}}
state == 1 {header = header $0 ORS}
state == 2 {print}
'
This command is a bit unwieldy, so you might want to put the AWK
script into a file, then you could use it like this:
git log -L33,34:src/main/java/org/toradocu/translator/Subject.java --date=short --color=always |
awk -v before=2016-11-18 -f gitlogbefore.awk
René
next prev parent reply other threads:[~2020-07-04 12:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-03 14:14 Git log: filtering by date and by lines do not work together Мария Долгополова
2020-07-04 12:56 ` René Scharfe [this message]
2020-07-04 12:56 ` [PATCH] revision: disable min_age optimization with line-log René Scharfe
2020-07-07 1:37 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2c4a6657-1a47-cfbb-21cd-04f131d2ed49@web.de \
--to=l.s.r@web.de \
--cc=dolgopolovamariia@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).