From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 9B98B1F405 for ; Mon, 17 Dec 2018 16:21:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387863AbeLQQVK (ORCPT ); Mon, 17 Dec 2018 11:21:10 -0500 Received: from cloud.peff.net ([104.130.231.41]:43924 "HELO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1727862AbeLQQVK (ORCPT ); Mon, 17 Dec 2018 11:21:10 -0500 Received: (qmail 3977 invoked by uid 109); 17 Dec 2018 16:21:10 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with SMTP; Mon, 17 Dec 2018 16:21:10 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 4404 invoked by uid 111); 17 Dec 2018 16:20:42 -0000 Received: from sigill.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.7) by peff.net (qpsmtpd/0.94) with (ECDHE-RSA-AES256-GCM-SHA384 encrypted) SMTP; Mon, 17 Dec 2018 11:20:42 -0500 Authentication-Results: peff.net; auth=none Received: by sigill.intra.peff.net (sSMTP sendmail emulation); Mon, 17 Dec 2018 11:21:08 -0500 Date: Mon, 17 Dec 2018 11:21:08 -0500 From: Jeff King To: Mark Kharitonov Cc: git@vger.kernel.org Subject: Re: Can git tell me which uncommitted files clash with the incoming changes? Message-ID: <20181217162108.GB914@sigill.intra.peff.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Mon, Dec 17, 2018 at 08:08:49AM -0500, Mark Kharitonov wrote: > C:\Dayforce\test [master ↓2 +0 ~2 -0 !]> git pull > error: Your local changes to the following files would be > overwritten by merge: > 2.txt > Please commit your changes or stash them before you merge. > Aborting > Updating 2dc8bd0..ea343f8 > C:\Dayforce\test [master ↓2 +0 ~2 -0 !]> > > Does git have a command that can tell me which uncommitted files cause > the this error? I can see them displayed by git pull, but I really do > not want to parse git pull output. That message is generated by merge-recursive, I believe after it's figured out which files would need to be touched. I don't offhand know of a way to get that _exact_ answer from another plumbing command. But in practice it would probably be reasonable to ask for the diff between your current branch and what you plan to merge, and cross-reference that with the list of files with local changes. Something like: git pull ;# this fails, but FETCH_HEAD is left over git diff-tree -z --name-only HEAD FETCH_HEAD >one git diff-index -z --name-only HEAD >two comm -z -12 one two would work on Linux, but "comm -z" is not portable (and I suspect you may not have comm at all on Windows). You can probably find a way to show the common elements of the two lists using the scripting language of your choice. The answer that gives will be overly broad (e.g., in a case where our local branch had touched file "foo" but other side had not, we'd consider "foo" as a difference the two-point diff-tree, whereas a real 3-way merge would realize that we'd keep our version of "foo"). But it might be good enough for your purposes. -Peff