git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* recover lost file
@ 2023-11-10  3:02 Malik Rumi
  2023-11-10  4:09 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Malik Rumi @ 2023-11-10  3:02 UTC (permalink / raw
  To: git

I am looking for a lost file that was accidentally deleted about 18
months ago. The docs I consulted are version 2.42.1. The git on my
machine is version 2.34.1

I followed the instructions on this page”
https://git-scm.com/book/en/v2/Git-Tools-Searching , the section “Line
Log Search”. But I got an error.

malikarumi@Tetuoan2:~/Projects/hattie$ git grep titlesplit
malikarumi@Tetuoan2:~/Projects/hattie$ git grep filesplit
malikarumi@Tetuoan2:~/Projects/hattie$ git log -L :titlesplit
fatal: -L argument not 'start,end:file' or ':funcname:file': :titlesplit
malikarumi@Tetuoan2:~/Projects/hattie$ git log -L :titlesplit:
fatal: -L argument not 'start,end:file' or ':funcname:file': :titlesplit:

I don’t know the purpose of the colon. Is it a boundary marker? Does
it belong at the front of the search object, the end, or both?
'start,end:file' sounds like the error message expects me to provide a
start and an end, to which the obvious reply is - If I knew where it
was, I wouldn’t be trying to find it.

What is the correct syntax?

Is there another search option?

Thanx




---
“None of you has faith until he loves for his brother or his neighbor
what he loves for himself.”


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: recover lost file
  2023-11-10  3:02 recover lost file Malik Rumi
@ 2023-11-10  4:09 ` Junio C Hamano
  2023-11-10  5:27   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2023-11-10  4:09 UTC (permalink / raw
  To: Malik Rumi; +Cc: git

Malik Rumi <malik.a.rumi@gmail.com> writes:

> I am looking for a lost file that was accidentally deleted about 18
> months ago. The docs I consulted are version 2.42.1. The git on my
> machine is version 2.34.1
>
> I followed the instructions on this page”
> https://git-scm.com/book/en/v2/Git-Tools-Searching , the section “Line
> Log Search”. But I got an error.
>
> malikarumi@Tetuoan2:~/Projects/hattie$ git grep titlesplit
> malikarumi@Tetuoan2:~/Projects/hattie$ git grep filesplit
> malikarumi@Tetuoan2:~/Projects/hattie$ git log -L :titlesplit
> fatal: -L argument not 'start,end:file' or ':funcname:file': :titlesplit
> malikarumi@Tetuoan2:~/Projects/hattie$ git log -L :titlesplit:
> fatal: -L argument not 'start,end:file' or ':funcname:file': :titlesplit:
>
> I don’t know the purpose of the colon. Is it a boundary marker? Does
> it belong at the front of the search object, the end, or both?
> 'start,end:file' sounds like the error message expects me to provide a
> start and an end, to which the obvious reply is - If I knew where it
> was, I wouldn’t be trying to find it.

Whatever documenttion that gave you "-L" perhaps did not give you a
good example.  

    $ git log -L"20,+5:helloworld.c"
    $ git log -L"/^titlesplit(/,/^}/:helloworld.c"
    $ git log -L":titlesplit:helloworld.c"

are ways to follow, how the range of lines in the helloworld.c file
of the CURRENTLY CHECKED OUT version, came about throughout the
history, going backwards.  The way to specify the range in the
current version of helloworld.c file may be different (the examples
show "starting at line #20, for five lines", "starting at the line
that matches the pattern "^titlesplit(", and ending at the line that
matches the pattern "^}", or "the body of the 'titlesplit' function
(according to the xfuncname logic)"), but they share one important
detail that may make the feature unsuitable for your use case.  You
need to exactly know where in the current version of which file the
line range you want to follow resides, but from your description I
am getting an impression that you do not even know the name of the
file.

You only said "a lost file" without giving any specifics, so it is
totally unclear to readers of your message how strings like
"titlesplit" and "filesplit" relate to what you are looking for.  In
the above I randomly made a blind guess that it might be a function
name, but I may be totally off the mark.

 - Do you mean "I think the file I removed had a name with either
   titlesplit or filesplit in it?"

 - Or do you mean "I know that the file had a definition of a
   function whose name was either titlesplit or filesplit?"

 - Or something completely different from the above two?

If I know all of the followings are true:

 - I had the necessary contents committed in Git;

 - I do not remember the filename at all, but I am sure I deleted it
   and committed the deletion some time ago;

 - I know the lost contents I am looking for had a string "frotz" in
   it.

then I would probably try

    $ git log -Sfrotz --diff-filter=D -p

which will look for all file deletions throughout the history,
limiting the output to those that had string "frotz" in them.

But again, it is unclear what useful clue you have to locate the
lost file from your description, so ...



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: recover lost file
  2023-11-10  4:09 ` Junio C Hamano
@ 2023-11-10  5:27   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2023-11-10  5:27 UTC (permalink / raw
  To: Malik Rumi; +Cc: git

Junio C Hamano <gitster@pobox.com> writes:

> You only said "a lost file" without giving any specifics, so it is
> totally unclear to readers of your message how strings like
> "titlesplit" and "filesplit" relate to what you are looking for.  In
> the above I randomly made a blind guess that it might be a function
> name, but I may be totally off the mark.
>
>  - Do you mean "I think the file I removed had a name with either
>    titlesplit or filesplit in it?"
>
>  - Or do you mean "I know that the file had a definition of a
>    function whose name was either titlesplit or filesplit?"
>
>  - Or something completely different from the above two?
>
> If I know all of the followings are true:
>
>  - I had the necessary contents committed in Git;
>
>  - I do not remember the filename at all, but I am sure I deleted it
>    and committed the deletion some time ago;
>
>  - I know the lost contents I am looking for had a string "frotz" in
>    it.
>
> then I would probably try
>
>     $ git log -Sfrotz --diff-filter=D -p
>
> which will look for all file deletions throughout the history,
> limiting the output to those that had string "frotz" in them.
>
> But again, it is unclear what useful clue you have to locate the
> lost file from your description, so ...

If the scenario were

 - I know the file were once committed in Git;

 - I do not remember the filename, but I think its name had either
   "frotz" or "nitfol" in it;

then I would try this instead:

    $ git log --diff-filter=D --summary -- '*frotz*' '*nitfol*'






^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-11-10  6:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-10  3:02 recover lost file Malik Rumi
2023-11-10  4:09 ` Junio C Hamano
2023-11-10  5:27   ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).