From owner-svn-src-head@freebsd.org Mon Jun 1 09:01:14 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9D50932F2D3; Mon, 1 Jun 2020 09:01:14 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49b8Kk3kCsz4Rk7; Mon, 1 Jun 2020 09:01:14 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7AB358E1D; Mon, 1 Jun 2020 09:01:14 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 05191E6G023383; Mon, 1 Jun 2020 09:01:14 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 05191EWi023381; Mon, 1 Jun 2020 09:01:14 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <202006010901.05191EWi023381@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Mon, 1 Jun 2020 09:01:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361688 - in head/usr.bin/diff: . tests X-SVN-Group: head X-SVN-Commit-Author: bapt X-SVN-Commit-Paths: in head/usr.bin/diff: . tests X-SVN-Commit-Revision: 361688 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jun 2020 09:01:14 -0000 Author: bapt Date: Mon Jun 1 09:01:13 2020 New Revision: 361688 URL: https://svnweb.freebsd.org/changeset/base/361688 Log: Restore compatibility with GNU diff regarding --label Various options to "diff(1)" show filenames, and traditionally make use of the "--label" parameter, if set. Restore this behaviour in BSD diff. While here add a regression test PR: 244533 Submitted by: Jamie Landeg-Jones MFC after: 3 days Modified: head/usr.bin/diff/diff.c head/usr.bin/diff/tests/diff_test.sh Modified: head/usr.bin/diff/diff.c ============================================================================== --- head/usr.bin/diff/diff.c Mon Jun 1 06:10:25 2020 (r361687) +++ head/usr.bin/diff/diff.c Mon Jun 1 09:01:13 2020 (r361688) @@ -465,6 +465,9 @@ print_only(const char *path, size_t dirlen, const char void print_status(int val, char *path1, char *path2, const char *entry) { + if (label[0] != NULL) path1 = label[0]; + if (label[1] != NULL) path2 = label[1]; + switch (val) { case D_BINARY: printf("Binary files %s%s and %s%s differ\n", Modified: head/usr.bin/diff/tests/diff_test.sh ============================================================================== --- head/usr.bin/diff/tests/diff_test.sh Mon Jun 1 06:10:25 2020 (r361687) +++ head/usr.bin/diff/tests/diff_test.sh Mon Jun 1 09:01:13 2020 (r361688) @@ -12,6 +12,7 @@ atf_test_case b230049 atf_test_case Bflag atf_test_case tabsize atf_test_case conflicting_format +atf_test_case label simple_body() { @@ -195,6 +196,17 @@ conflicting_format_body() atf_check -s exit:1 -o ignore -e ignore diff --normal --normal A B } +label_body() +{ + printf "\tA\n" > A + + atf_check -o inline:"Files hello and world are identical\n" \ + -s exit:0 diff --label hello --label world -s A A + + atf_check -o inline:"Binary files hello and world differ\n" \ + -s exit:1 diff --label hello --label world `which diff` `which ls` +} + atf_init_test_cases() { atf_add_test_case simple @@ -209,4 +221,5 @@ atf_init_test_cases() atf_add_test_case Bflag atf_add_test_case tabsize atf_add_test_case conflicting_format + atf_add_test_case label }