git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Elijah Newren <newren@gmail.com>
Cc: biswaranjan.nitrkl@gmail.com,
	Bryan Turner <bturner@atlassian.com>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: Retrieving a file in git that was deleted and committed
Date: Tue, 11 Dec 2018 04:46:33 -0500	[thread overview]
Message-ID: <20181211094633.GA31588@sigill.intra.peff.net> (raw)
In-Reply-To: <CABPp-BHjR7Wq-D9tFMyPHZE1ogL5udOt8ri1rN3E1CasfD-2PQ@mail.gmail.com>

On Mon, Dec 10, 2018 at 01:33:18PM -0800, Elijah Newren wrote:

> Hmm...sure, if the file is deleted on the only relevant branch through
> history...but what if there were another branch where it weren't
> deleted?  What does git blame do then?
> 
> In other words, do NOT restore the file as biswaranjan suggested, but
> instead restore it this way[1]:
> 
> git checkout -b keep-foo $REVISION_BEFORE_FOO_DELETED
> git commit --allow-empty -m "We want to keep foo"
> git checkout A
> git merge --no-commit keep-foo
> git checkout keep-foo -- foo.txt
> git commit
> 
> 
> Now, when you run
>   git blame foo.txt
> 
> blame should notice that foo.txt didn't exist in the first parent
> history on A, so it won't bother walking it to find that at some point
> foo.txt did exist there.  Instead, it'll walk down the second parent
> and follow its history, where it should keep walking back and show all
> the old changes...right?  Or did I mess up my testcase and
> misunderstand something somehow?

Yeah, I think that should work, and is a clever way of representing in
the actual history graph what you're we're trying to express. And it
shouldn't have any real downsides.

-Peff

  reply	other threads:[~2018-12-11  9:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-07  6:49 Retrieving a file in git that was deleted and committed biswaranjan panda
2018-12-07  6:55 ` Bryan Turner
2018-12-07  7:07   ` biswaranjan panda
2018-12-07  7:20     ` Jeff King
2018-12-07  7:37       ` Bryan Turner
2018-12-07 21:50         ` biswaranjan panda
2018-12-08  7:29           ` Jeff King
2018-12-09  0:07             ` biswaranjan panda
2018-12-11  1:19             ` Junio C Hamano
2018-12-10 21:33       ` Elijah Newren
2018-12-11  9:46         ` Jeff King [this message]
2018-12-10 15:12 ` Sergey Organov

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181211094633.GA31588@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=biswaranjan.nitrkl@gmail.com \
    --cc=bturner@atlassian.com \
    --cc=git@vger.kernel.org \
    --cc=newren@gmail.com \
    /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.
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).