Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gitdiff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pascal Engeler
gitdiff
Commits
76fc449f
Commit
76fc449f
authored
4 years ago
by
Pascal Engeler
Browse files
Options
Downloads
Patches
Plain Diff
initial commit
parents
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gitdiff
+237
-0
237 additions, 0 deletions
gitdiff
with
237 additions
and
0 deletions
gitdiff
0 → 100755
+
237
−
0
View file @
76fc449f
#!/bin/bash
NUMARGS
=
$#
if
((
$NUMARGS
==
0
))
then
echo
-e
"Info:
\n
gitdiff generates a compiled latexdiff file from different git commits."
echo
-e
"Usage:
\n
gitdiff <other hash> filename.tex
\n
gitdiff <new hash> <old hash> filename.tex
\n
gitdiff <new hash> <old hash> <path to file> filename.tex"
fi
if
((
$NUMARGS
==
1
))
then
echo
-e
"Info:
\n
gitdiff generates a compiled latexdiff file from different git commits."
echo
-e
"Usage:
\n
gitdiff <other hash> filename.tex
\n
gitdiff <new hash> <old hash> filename.tex
\n
gitdiff <new hash> <old hash> <path to file> filename.tex"
fi
if
((
$NUMARGS
==
2
))
then
GITSTATUS
=
$(
git diff
--stat
)
if
[
-z
"
$GITSTATUS
"
]
then
:
else
echo
"Please clean your working tree first."
exit
1
fi
CURRENTHASH
=
$(
git rev-parse HEAD
)
OTHERHASH
=
$1
FILENAME
=
$2
TEMPDIR
=
${
CURRENTHASH
}
_
${
OTHERHASH
}
_GITDIFF_TEMPDIR_314159
DIFFFILE
=
gitdiff_
${
CURRENTHASH
}
_
${
OTHERHASH
}
if
[
-f
"
$DIFFFILE
"
]
then
echo
-e
"Please remove
$DIFFFILE
first."
exit
1
fi
if
[
-d
"
$TEMPDIR
"
]
then
echo
-e
"Please remove
$TEMPDIR
first"
exit
1
fi
if
git cat-file
-e
$OTHERHASH
^
{
commit
}
then
echo
-e
"
$OTHERHASH
is valid"
else
echo
-e
"Fatal: Hash
$OTHERHASH
is invalid"
exit
1
fi
git checkout
$OTHERHASH
if
[
-f
"
$FILENAME
"
]
then
:
else
echo
"Fatal:
$FILENAME
does not exist"
git checkout -
exit
1
fi
mkdir
$TEMPDIR
cp
$FILENAME
$TEMPDIR
git checkout -
latexdiff
$TEMPDIR
/
$FILENAME
$FILENAME
>
$DIFFFILE
.tex
pdflatex
$DIFFFILE
.tex
bibtex
$DIFFFILE
.tex
pdflatex
$DIFFFILE
.tex
rm
-rf
$DIFFFILE
.aux
$DIFFFILE
.out
$DIFFFILE
.log
#rm -rf $DIFFFILE.tex
rm
-rf
$TEMPDIR
fi
if
((
$NUMARGS
==
3
))
then
GITSTATUS
=
$(
git diff
--stat
)
if
[
-z
"
$GITSTATUS
"
]
then
:
else
echo
"Please clean your working tree first."
exit
1
fi
CURRENTHASH
=
$(
git rev-parse HEAD
)
NEWHASH
=
$1
OLDHASH
=
$2
FILENAME
=
$3
TEMPDIR
=
${
NEWHASH
}
_
${
OLDHASH
}
_GITDIFF_TEMPDIR_314159
DIFFFILE
=
gitdiff_
${
NEWHASH
}
_
${
OLDHASH
}
if
[
-f
"
$DIFFFILE
"
]
then
echo
-e
"Please remove
$DIFFFILE
first."
exit
1
fi
if
[
-d
"
$TEMPDIR
"
]
then
echo
-e
"Please remove
$TEMPDIR
first"
exit
1
fi
if
git cat-file
-e
$OLDHASH
^
{
commit
}
then
echo
-e
"
$OLDHASH
is valid"
else
echo
-e
"Fatal: Hash
$OLDHASH
is invalid"
exit
1
fi
if
git cat-file
-e
$NEWHASH
^
{
commit
}
then
echo
-e
"
$NEWHASH
is valid"
else
echo
-e
"Fatal: Hash
$NEWHASH
is invalid"
exit
1
fi
git checkout
$OLDHASH
if
[
-f
"
$FILENAME
"
]
then
:
else
echo
"Fatal:
$FILENAME
does not exist"
git checkout -
exit
1
fi
mkdir
$TEMPDIR
cp
$FILENAME
$TEMPDIR
/
$FILENAME
git checkout -
git checkout
$NEWHASH
if
[
-f
"
$FILENAME
"
]
then
:
else
echo
"Fatal:
$FILENAME
does not exist"
rm
-rf
$TEMPDIR
git checkout -
exit
1
fi
latexdiff
$TEMPDIR
/
$FILENAME
$FILENAME
>
$DIFFFILE
.tex
git checkout -
pdflatex
$DIFFFILE
.tex
bibtex
$DIFFFILE
.tex
pdflatex
$DIFFFILE
.tex
rm
-rf
$DIFFFILE
.aux
$DIFFFILE
.out
$DIFFFILE
.log
#rm -rf $DIFFFILE.tex
rm
-rf
$TEMPDIR
fi
if
((
$NUMARGS
==
4
))
then
CURRENTDIR
=
$(
pwd
)
NEWHASH
=
$1
OLDHASH
=
$2
DIRECTORY
=
$3
FILENAME
=
$4
if
[
-d
"
$DIRECTORY
"
]
then
:
else
echo
-e
"Fatal:
$DIRECTORY
doesn't exist"
exit
1
fi
if
$(
git
-C
$DIRECTORY
rev-parse
)
then
:
else
echo
"Fatal: Not a git repository"
cd
$CURRENTDIR
exit
1
fi
cd
$DIRECTORY
GITSTATUS
=
$(
git diff
--stat
)
if
[
-z
"
$GITSTATUS
"
]
then
:
else
echo
"Please clean your working tree first."
cd
$CURRENTDIR
exit
1
fi
if
$(
git cat-file
-e
$NEWHASH
^
{
commit
}
)
then
echo
-e
"
$NEWHASH
is valid"
else
echo
-e
"Fatal: Hash
$NEWHASH
is invalid"
cd
$CURRENTDIR
exit
1
fi
if
$(
git cat-file
-e
$OLDHASH
^
{
commit
}
)
then
echo
-e
"
$OLDHASH
is valid"
else
echo
-e
"Fatal: Hash
$OLDHASH
is invalid"
cd
$CURRENTDIR
exit
1
fi
CURRENTHASH
=
$(
git rev-parse HEAD
)
TEMPDIR
=
${
NEWHASH
}
_
${
OLDHASH
}
_GITDIFF_TEMPDIR_314159
DIFFFILE
=
gitdiff_
${
NEWHASH
}
_
${
OLDHASH
}
if
[
-d
"
$TEMPDIR
"
]
then
echo
-e
"Please remove
$TEMPDIR
from the repo first"
cd
$CURRENTDIR
exit
1
fi
git checkout
$OLDHASH
if
[
-f
"
$FILENAME
"
]
then
:
else
echo
"Fatal:
$FILENAME
does not exist"
git checkout -
cd
$CURRENTDIR
exit
1
fi
mkdir
$TEMPDIR
cp
$FILENAME
$TEMPDIR
/
$FILENAME
git checkout -
git checkout
$NEWHASH
if
[
-f
"
$FILENAME
"
]
then
:
else
echo
"Fatal:
$FILENAME
does not exist"
rm
-rf
$TEMPDIR
git checkout -
cd
$CURRENTDIR
exit
1
fi
latexdiff
$TEMPDIR
/
$FILENAME
$FILENAME
>
$DIFFFILE
.tex
git checkout -
pdflatex
$DIFFFILE
.tex
bibtex
$DIFFFILE
.tex
pdflatex
$DIFFFILE
.tex
rm
-rf
$DIFFFILE
.aux
$DIFFFILE
.out
$DIFFFILE
.log
#rm -rf $DIFFFILE.tex
rm
-rf
$TEMPDIR
mv
$DIFFFILE
.pdf
$CURRENTDIR
/
${
FILENAME
//.
}
_
$DIFFFILE
.pdf
cd
$CURRENTDIR
fi
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment